Android Build.gradle DuplicateFileException 错误

标签 android gradle

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

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/maven/com.firebase/firebase-client-jvm/pom.properties File1: C:\Users\Owner\AndroidStudioProjects\RealChatHusk\app\libs\firebase-client-android-2.5.2.jar File2: 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'
}

最佳答案

在 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'

关于Android Build.gradle DuplicateFileException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35810807/

相关文章:

java - 如何在运行 Aeron 示例时设置 Aeron 订阅者和发布者数量限制

android - 无法从 android 7.1 及以上设备的图库中选择图像

javascript - html5 视频标签无法使用 cordova 2.9.0 和 jquery1.9.0 在 phonegap android 中播放 .mp4 视频?

android - 解决重复的类依赖性-Gradle

gradle - 为什么android gradle maven发布工件bundleRelease找不到

android - 如何知道gradlescript使用哪个版本来构建android应用

android - 如何在 Android 中实现 Google Places API?

android - 远程媒体播放器 HTTP 响应处理

android - 如何通过代码将xml图层列表转换为layerdrawable

android - 我安装了Android Studio 3.1.2。我注意到以下错误