android 开发中遇到的运行时bug!!!

1. 

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

遇到这种情况最直接解决办法就是:在app级别的build.gradle文件中添加

multiDexEnabled true  即可
android {
   
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

2.

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
> Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.0.1) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

遇到这种情况解决办法:在app级别的build.gradle文件中添加

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}

android {

}
configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}
dependencies {
    
}

猜你喜欢

转载自blog.csdn.net/keke921231/article/details/82967688