天天看点

Android导入compile 'com.roughike:bottom-bar:2.3.1'会导致V7包报错

出现问题

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

原因是compile 'com.roughike:bottom-bar:2.3.1这个依赖同样依赖了v7包,导致两个V7包冲突了

出现了这个错误

Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Android导入compile 'com.roughike:bottom-bar:2.3.1'会导致V7包报错

解决方法通过指定V7包的方法解决冲突 ,在compile 'com.roughike:bottom-bar:2.3.1添加注解指定使用版本

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "org.jetbrains.anko:anko:$anko_version"
    implementation ('com.roughike:bottom-bar:2.3.1'){
        exclude group: 'com.android.support'
        exclude module: 'appcompat-v7'
        exclude module: 'design'
    }
}