本文介绍了Gradle生成时发出的问题在APK META-INF / LICENSE中复制的重复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任务`:app:transformResourcesWithMergeJavaResForDebug`的执行失败。
com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK中拷贝的重复文件META-INF / LICENSE
File1:C:\Users\admin \.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson的注解 - 2.2.2.jar
File2:C:\ Users \admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2 \d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\\jackson-core-2.2.2.jar
File3:C:\ Users \admin\.gradle\caches\modules-2\files-2.1\com.fasterxml .jackson.core \ jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar
我试过使用
packagingOptions {
pre>
exclude'META-I NF / LICENSE.txt'
排除'META-INF / LICENSE'
排除'META-INF / license.txt'
}
这个工程,但我不想排除许可证,请告诉我如何避免使用这个
apply plugin:'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion24.0.2
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName1.0
}
buildTypes {
$ {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
$ b $ dependencies {
compile fileTree(dir:'libs',include:['* .jar'])
testCompile'junit:junit:4.12'
编译'com.android.support:appcompat-v7:24 .2.1'
compile'com.android.support:support-v4:24.2.1'
compile'com.android.support:design:24.2.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile'com.google.firebase:firebase-storage:9.4.0'
compile'com.google.firebase:firebase-messaging :9.4.0'
compile'com.google.firebase:firebase-auth:9.4.0'
compile'com.firebase:firebase-client-android:2.5.2'
compile'com.squareup.retrofit2:retrofit:2.1.0'
compile'com.squareup.okhttp3:okhttp:3.4.1'
compile'com.squareup.retrofit:converter-gson :2.0.0-beta2'
}
这是我的gradle,请让我知道哪些依赖是造成这个问题的解决方案
您正在混合使用Firebase客户端的版本,你更多的问题。
使用单个版本对于所有Firebase依赖项(例如9.4.0),都可以使用它:
compile'com.google.firebase:firebase-core:9.4 .0'
compile'com.google.firebase:firebase-storage:9.4.0'
compile'com.google.firebase:firebase-messaging:9.4.0'
compile'com .google.firebase:firebase-auth:9.4.0'
compile'com.google.firebase:firebase-database:9.4.0'// this this changed
Execution failed for task `:app:transformResourcesWithMergeJavaResForDebug`. com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE File1: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar File2: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar File3: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar
I have tried using
packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/license.txt' }
and this works but I don't want to exclude the licence please tell how I can avoid it with out using this
apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.2" defaultConfig { minSdkVersion 16 targetSdkVersion 24 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:support-v4:24.2.1' compile 'com.android.support:design:24.2.1' compile 'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-storage:9.4.0' compile 'com.google.firebase:firebase-messaging:9.4.0' compile 'com.google.firebase:firebase-auth:9.4.0' compile 'com.firebase:firebase-client-android:2.5.2' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' }
here is my gradle which has many dependencies so please let me know which dependencies are causing the issue
解决方案You're mixing versions of the Firebase client, which is guaranteed to give you more problems down the line.
Use a single version for all your Firebase dependencies, such as 9.4.0:
compile 'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-storage:9.4.0' compile 'com.google.firebase:firebase-messaging:9.4.0' compile 'com.google.firebase:firebase-auth:9.4.0' compile 'com.google.firebase:firebase-database:9.4.0' // this one changed
这篇关于Gradle生成时发出的问题在APK META-INF / LICENSE中复制的重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!