错误构建APK {重复条目:com / google / android / gms / gcm / INetworkTaskCallback $ Stub.class}

时间:2017-03-25 11:53:54

标签: java android firebase gradle apk

您好我正在尝试构建APK,但我在Android Studio中提取此问题。

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
  

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / android / gms / gcm / INetworkTaskCallback $ Stub.class

Gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
     defaultConfig {
      applicationId "com.example.mouad.fixmyphone"
      minSdkVersion 15
      targetSdkVersion 25
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner    "android.support.test.runner.AndroidJUnitRunner"
      // Enabling multidex support.
      multiDexEnabled true
   }
   dexOptions {
        javaMaxHeapSize "4g"
  }
   buildTypes {
      release {
           minifyEnabled false
               proguardFiles getDefaultProguardFile('proguard-android.txt'),   'proguard-rules.pro'
        }
    }
   useLibrary 'org.apache.http.legacy'

 }
 android {
     packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
      }
 }

 dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',          {
    exclude group: 'com.android.support', module: 'support-annotations'
   })
   compile 'com.android.support:appcompat-v7:25.1.1'
   compile 'com.android.support:design:25.1.1'
   compile 'com.android.support:support-v4:25.1.1'
   compile 'com.android.support:multidex:1.0.1'
   compile 'com.miguelcatalan:materialsearchview:1.4.0'
   compile 'com.google.firebase:firebase-core:10.2.1'
   compile 'com.google.firebase:firebase-messaging:10.2.1'
   compile 'com.firebase:firebase-client-android:2.5.2'
   compile 'com.firebase:firebase-jobdispatcher:0.5.2'
   compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'
   testCompile 'junit:junit:4.12'
   }
    apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

Firebase JobDispatcher的文档说只包含其中一个:

compile 'com.firebase:firebase-jobdispatcher:0.5.2'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'

你包括两者。由于您的应用不依赖com.google.android.gms:play-services-gcm,因此您应该只包含此库:

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

从依赖项中删除此行:

compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'