我们在写代码时候总会借鉴一些第三方库,有的是别人写的比较优秀的,有的则是google官方提供的,但是我们在依赖之后编译运行时候总会出各种各样的问题:
1、Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
2、“Error:Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:appcompat-v7' has different version for the compile (27.0.2) and runtime (27.1.0) classpath. You should manually set the same version via DependencyResolution”,
针对上面的support:appcompat库我们可以像下面一样子来指定自己所依赖的版本:
在build.gradle的dependencies中添加如下代码即可
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
//循环一个个的依赖库
resolutionStrategy.eachDependency {