我刚刚更新了Android Studio,因此无法构建我的应用。我收到一个看起来像这样的例外:
Error: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: /Users/andersvincentlund/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.2/d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b/jackson-core-2.2.2.jar
File2: /Users/andersvincentlund/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/3c8f6018eaa72d43b261181e801e6f8676c16ef6/jackson-databind-2.2.2.jar
File3: /Users/andersvincentlund/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.2.2/285cb9c666f0f0f3dd8a1be04e1f457eb7b15113/jackson-annotations-2.2.2.jar
我搜索了这种类型的错误,并建议添加:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '...'
}
在gradle中的android子句中。这没有任何改变(除了我的构建可能是非法的,因为我会忽略OS代码的许可?)。有没有人知道如何解决这个问题?我希望更新不会破坏代码。
编辑:
我收到了关于gradle文件的评论,因此我发布了以下全部内容:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
packagingOptions {
exclude 'META-INF/NOTICE' // will not include NOTICE file
exclude 'META-INF/LICENSE' // will not include LICENSE file
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
signingConfigs {
config {
keyPassword 'XXXXX'
storeFile file('/XXXXX/XXXXX/XXXXX/android.keystore')
storePassword 'XXXXX'
keyAlias 'XXXXX'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "XXXXX"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.config
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
apt 'com.google.dagger:dagger-compiler:2.5'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.dagger:dagger:2.5'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.firebase:firebase-client-android:2.4.0'
compile group: 'com.google.guava', name: 'guava', version: '19.0'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:2)
只需删除:
compile fileTree(include: ['*.jar'], dir: 'libs')
这
dependencies {}
jackson-core-2.2.2.jar
中已存在libs/
,但另一个依赖项正在尝试在外部添加它。
答案 1 :(得分:-1)
请添加以下行
packagingOptions {
exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.xml'
exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.properties'}