1、异常情况描述(AS项目接入第三方依赖报错)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'slice.jar (io.airlift:slice:0.5)' to match attributes {artifactType=android-dex, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=16, org.gradle.usage=java-runtime-jars}.
> Execution failed for DexingWithClasspathTransform: E:\android_studio_gradle_repository\.gradle\caches\modules-2\files-2.1\io.airlift\slice\0.5\c921c01e56aa66e38c97a73602bfc84c849d0733\slice-0.5.jar.
> Error while dexing.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
2、异常处理
经过排查,定位在build.gradle文件配置中
需要将build.gradle中android.enableJetifier的值修改为false
以下配置可参考
android {
defaultConfig {
multiDexEnabled true
}
packagingOptions {
/*解决异常: More than one file was found with OS independent path 'META-INF/DEPENDENCIES'*/
/*这个问题是因为引入了多个第三方库,而第三方库中拥有很多重名的文件,所以会报这种错误*/
exclude 'META-INF/DEPENDENCIES'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
文章来源
发表评论