【问题标题】:Android Build.gradle DuplicateFileException ErrorAndroid Build.gradle DuplicateFileException 错误
【发布时间】:2016-03-05 06:15:01
【问题描述】:

所以我正在尝试将Firebase SDK 合并到 android studio 中,并且我严格按照文档进行操作。这是我的错误和Gradle 文件。感谢您的帮助。

错误:任务 ':app:transformResourcesWithMergeJavaResForDebug' 执行失败。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在 APK META-INF/maven/com.firebase/firebase-client-jvm/pom.properties 中复制的重复文件 文件 1:C:\Users\Owner\AndroidStudioProjects\RealChatHusk\app\libs\firebase-client-android-2.5.2.jar 文件2:C:\Users\Owner.gradle\caches\modules-2\files-2.1\com.firebase\firebase-client-jvm\2.5.2\91731b8f5868a3e8a8a773f29b8d06b5c358f5bb\firebase-client-jvm-2.5.2.jar

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.owner.realchathusk"
    minSdkVersion 22
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}
 }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:23.1.1'

compile 'com.android.support:support-v4:23.1.1'

compile 'com.android.support:design:23.1.1'

compile 'com.firebase:firebase-client-android:2.5.2'
}

【问题讨论】:

  • compile 'com.firebase:firebase-client-android:2.3.1' 然后清理重建您的项目。
  • 修复后出现同样的错误

标签: android gradle


【解决方案1】:

在 build.gradle 文件中添加以下文本解决问题

packagingOptions {
    exclude  'jsr305_annotations/Jsr305_annotations.gwt.xml'
    exclude  'build-data.properties'
 }

如果出现更多错误 DuplicateFileException 添加带有排除的文件。 喜欢:

错误

Duplicate files copied in APK jsr305_annotations/Jsr305_annotations.gwt.xml 

解决方案

exclude  'jsr305_annotations/Jsr305_annotations.gwt.xml'

【讨论】:

    【解决方案2】:

    试试这个代码:

    compile 'com.android.support:appcompat-v7:23.2.0'
    
    compile 'com.android.support:support-v4:23.2.0'
    
    compile 'com.android.support:design:23.2.0'
    

    【讨论】:

      猜你喜欢
      • 2016-08-10
      • 1970-01-01
      • 2016-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多