java - 添加新库时出现错误程序类型已存在 : Program type already present: androidx. recyclerview.widget.AdapterHelper$Callback

标签 java android

当我尝试向项目添加新库然后运行我的应用程序时,出现此错误:

Program type already present: Program type already present: androidx.recyclerview.widget.AdapterHelper$Callback

以下是我尝试添加的库

implementation 'com.android.support:design:28.0.0'

这是我的应用程序级别 gradle 文件:

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    google()
    jcenter()
}

configurations {
    //compile.exclude module: 'support-v4'
}

configurations.all {
    exclude group: 'com.google.firebase', module: 'firebase-core'
}

dependencies {

    implementation 'com.android.support:design:28.0.0' // whene i added this library 

    implementation 'androidx.core:core:1.2.0-rc01'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.1.0'

    compileOnly 'org.checkerframework:checker-qual:2.5.2'
    compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'com.google.firebase:firebase-config:19.0.4'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.android.gms:play-services-vision:19.0.0'
    implementation 'com.google.android.gms:play-services-wallet:17.0.0'
    implementation 'com.google.android.gms:play-services-wearable:17.0.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'net.hockeyapp.android:HockeySDK:5.2.0'
    implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
    implementation 'com.stripe:stripe-android:2.0.2'






}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig.applicationId = "org.telegram.messenger"

    sourceSets.main.jniLibs.srcDirs = ['./jni/']

    externalNativeBuild {
        ndkBuild {
            path "jni/Android.mk"
        }
    }

    lintOptions {
        disable 'MissingTranslation'
        disable 'ExtraTranslation'
        disable 'BlockedPrivateApi'
    }

    dexOptions {
        jumboMode = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    signingConfigs {
        debug {
            storeFile file("config/key.keystore")
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }

        release {
            storeFile file("config/key.keystore")
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }

    buildTypes {
        debug {
            debuggable true
            jniDebuggable true
            signingConfig signingConfigs.debug
            applicationIdSuffix ".beta"
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debugMultidex {
            initWith debug
            minifyEnabled false
            multiDexEnabled true
            dependencies {
                implementation 'com.android.support:multidex:1.0.3'
            }
            manifestPlaceholders = [applicationClassName: "MultiDexApplicationLoader"]
        }

        HA {
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.debug
            applicationIdSuffix ".beta"
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            debuggable false
            jniDebuggable false
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets.debug {
        manifest.srcFile 'config/debug/AndroidManifest.xml'
    }

    sourceSets.debugMultidex {
        manifest.srcFile 'config/debug/AndroidManifest.xml'
        java.srcDirs = ['src/multidex/java']
    }

    sourceSets.HA {
        manifest.srcFile 'config/debug/AndroidManifest.xml'
    }

    sourceSets.release {
        manifest.srcFile 'config/release/AndroidManifest.xml'
    }

    flavorDimensions "minApi"

    productFlavors {
        armv7 {
            ndk {
                abiFilters "armeabi-v7a"
            }
            ext {
                abiVersionCode = 1
            }
        }
        x86 {
            ndk {
                abiFilters "x86"
            }
            ext {
                abiVersionCode = 2
            }
        }
        armv7_SDK23 {
            ndk {
                abiFilters "armeabi-v7a"
            }
            sourceSets.debug {
                manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
            }
            sourceSets.release {
                manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
            }
            minSdkVersion 23
            ext {
                abiVersionCode = 3
            }
        }
        x86_SDK23 {
            ndk {
                abiFilters "x86"
            }
            sourceSets.debug {
                manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
            }
            sourceSets.release {
                manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
            }
            minSdkVersion 23
            ext {
                abiVersionCode = 4
            }
        }
        arm64 {
            ndk {
                abiFilters "arm64-v8a"
            }
            ext {
                abiVersionCode = 5
            }
        }
        x64 {
            ndk {
                abiFilters "x86_64"
            }
            ext {
                abiVersionCode = 6
            }
        }
        arm64_SDK23 {
            ndk {
                abiFilters "arm64-v8a"
            }
            sourceSets.debug {
                manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
            }
            sourceSets.release {
                manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
            }
            minSdkVersion 23
            ext {
                abiVersionCode = 7
            }
        }
        x64_SDK23 {
            ndk {
                abiFilters "x86_64"
            }
            sourceSets.debug {
                manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
            }
            sourceSets.release {
                manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
            }
            minSdkVersion 23
            ext {
                abiVersionCode = 8
            }
        }
        afat {
            sourceSets.debug {
                manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
            }
            sourceSets.release {
                manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
            }
            ext {
                abiVersionCode = 0
            }
        }
    }

    defaultConfig.versionCode = 1710

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            output.getProcessManifestProvider().get().doLast {
                def abiVersion = variant.productFlavors.get(0).abiVersionCode

                def outputDir = manifestOutputDirectory
                File directory
                if (outputDir instanceof File) {
                    directory = outputDir
                } else {
                    directory = outputDir.get().asFile
                }

                String manifestPath = directory.toString() + "/AndroidManifest.xml"
                def manifestContent = file(manifestPath).getText()

                manifestContent = manifestContent.replace(String.format('android:versionCode="%d"', defaultConfig.versionCode), String.format('android:versionCode="%s"', defaultConfig.versionCode * 10 + abiVersion))
                file(manifestPath).write(manifestContent)
            }
        }
    }

    variantFilter { variant ->
        def names = variant.flavors*.name
        if (variant.buildType.name != "release" && !names.contains("afat")) {
            setIgnore(true)
        }
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionName "5.11.0"

        vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

        externalNativeBuild {
            ndkBuild {
                arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "-j8"
                abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
            }
        }

        manifestPlaceholders = [applicationClassName: "ApplicationLoader"]
    }
}

apply plugin: 'com.google.gms.google-services'

我真的很困惑要解决这个问题 谢谢

最佳答案

通过添加此代码修复的问题:

configurations {
    compile.exclude group: 'androidx.recyclerview', module: 'recyclerview'
}

关于java - 添加新库时出现错误程序类型已存在 : Program type already present: androidx. recyclerview.widget.AdapterHelper$Callback,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59345498/

相关文章:

java - 使用 open csv 时从 csv 中删除双引号

java - 异步写入似乎在 Cassandra 中被破坏

java - 在java中访问父类中的子常量

android - 如何在 Android 应用程序中收集 LogCat 消息

android - 如何更改进度条的默认颜色?

android - Xamarin Sql Server 无法建立连接

java - 我不明白我的 Android 应用程序的错误在哪里

java - 如何在libgdx中通过单击和双击实现不同的事件?

java - 服务器没有收到客户端的请求

android - 带有 ssl iframe 的 ssl 页面在 android 5.1 上损坏