错误:添加QR阅读器模块时,程序类型已经存在

时间:2018-08-10 16:28:34

标签: android android-gradle build.gradle zxing

我在build.gradle中添加了以下行: implementation 'com.journeyapps:zxing-android-embedded:3.5.0'

,然后在尝试构建项目时收到此错误:

Error: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

任何人都可以解释该错误的含义

这是我当前的整个构建过程:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.chaimovy.myapplication"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

configurations.all {exclude group: 'android.support.v4.app', module: 'INotificationSideChannel'}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'org.web3j:core:3.3.1-android'
    implementation 'com.google.android.material:material:1.0.0-alpha1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
}

还有谁能建议一种通过添加新依赖项来解决它的方法?

1 个答案:

答案 0 :(得分:0)

该库具有以下传递依赖项:

com.android.support:support-v4:25.3.1

您的某些其他应用程序依赖项与传递依赖项冲突:

com.android.support:support-v4:25.1.0

如果您不想使用zxing-android-embedded随附的传递依赖项,可以将其排除:

implementation('com.journeyapps:zxing-android-embedded:3.5.0') {
    exclude group: 'com.android.support', module: 'support-v4'
}

您还可以探索解决冲突的策略:

android {
    configurations.all {
        resolutionStrategy.force 'com.android.support:support-v4:25.1.0'
    }
}

您可以使用以下gradle命令查看所有传递依赖项:

./gradlew -q dependencies app:dependencies