构建APK时出现以下错误。
Duplicate files copied in APK META-INF/android.arch.lifecycle_runtime.version
File1: /Users/.../build/intermediates/exploded-aar/com.google.android.gms/play-services-base/12.0.0/jars/classes.jar
File2: /Users/.../build/intermediates/exploded-aar/android.arch.lifecycle/runtime/1.1.1/jars/classes.jar
在app build.gradle中添加的依赖项如下
compile "android.arch.lifecycle:runtime:1.1.1"
compile "android.arch.lifecycle:extensions:1.1.1"
compile "com.google.android.gms:play-services-base:12.0.0"
compile "com.google.android.gms:play-services-identity:12.0.0"
compile "com.google.android.gms:play-services-auth:12.0.0"
compile "com.google.android.gms:play-services-auth-api-phone:12.0.0"
答案 0 :(得分:0)
在APK META-INF / android.arch.lifecycle_runtime.version中复制的重复文件
文件1:/ Users /.../ build / intermediates / exploded-aar / com.google.android.gms / play-services-base / 12.0.0 / jars / classes.jar
文件2:/ Users /.../ build / intermediates / exploded-aar / android.arch.lifecycle / runtime / 1.1.1 / jars / classes.jar
它说它找到了两个具有相同库的文件,其中一个在您的第一次编译中:
compile "android.arch.lifecycle:runtime:1.1.1"
然后是另一个
compile "com.google.android.gms:play-services-base:12.0.0"
这是因为com.google.android.gms:play-services-base:12.0.0
已经包含lifecycle:runtime
,只需删除第一行,然后再次重建/清理项目即可。
如果它不起作用,请按照this issue的指示将其排除在gradle.build
中
exclude 'META-INF/android.arch.lifecycle_runtime.version'
exclude 'META-INF/com.android.support_support-v4.version'
exclude 'META-INF/com.android.support_support-fragment.version'
exclude 'META-INF/com.android.support_support-media-compat.version'
exclude 'META-INF/com.android.support_support-core-utils.version'
exclude 'META-INF/com.android.support_support-compat.version'
exclude 'META-INF/com.android.support_support-core-ui.version'
另外,您也可以查看此问题:Similar problem