2017-09-20 170 views
1

我试图构建APK,但有一个错误,当我尝试使它。Android工作室APK建立错误transformClassesWithJarMergingForDebug

错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败。

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback.class

以下是我的build.gradle(模块:APP)

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "jordan.personicle" 
     minSdkVersion 19 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 

    compile files('libs/ajt-2.9.jar', 'libs/javaml-0.1.7.jar') 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support:design:26.+' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.google.android.gms:play-services:11.0.1' 
    compile 'com.google.firebase:firebase-database:10.2.1' 
    compile 'com.google.firebase:firebase-core:10.0.1' 
    compile 'com.google.firebase:firebase-messaging:10.0.1' 

    compile 'com.firebase:firebase-jobdispatcher:0.6.0' 

    compile 'org.jsoup:jsoup:1.7.3' 
    compile 'com.android.support:multidex:1.0.0' 

    testCompile 'junit:junit:4.12' 
} 

apply plugin: 'com.google.gms.google-services' 

这是我的build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
     repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 
     classpath 'com.google.gms:google-services:3.0.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

我觉得没有重复的GCM。问题是什么?

感谢,

+0

问题是编译“com.google.android.gms:发挥服务:11.0.1' 。我应该如何解决这个问题?哪个依赖关系可以与上面的重复? –

回答

0

请确保您使用在所有的谷歌播放服务库相同的版本:

compile 'com.google.android.gms:play-services:11.0.4' 
compile 'com.google.firebase:firebase-database:11.0.4' 
compile 'com.google.firebase:firebase-core:11.0.4' 
compile 'com.google.firebase:firebase-messaging:11.0.4' 

https://stackoverflow.com/a/42610163/1370087

+1

感谢您的回复。我试图同步版本,但仍然是相同的错误。编译'com.google.firebase:firebase-database:10.2.1' compile'c​​om.google.firebase:firebase-core:10.2.1' compile'c​​om.google.firebase:firebase-messaging:10.2.1' –

+0

看到我更新的答案,它适用于我 – Benjamin

+1

谢谢本杰明。但它仍然显示相同的错误。 –

相关问题