【问题标题】:Error Build APK {duplicate entry: com/google/android/gms/gcm/INetworkTaskCallback$Stub.class}错误构建 APK {重复条目:com/google/android/gms/gcm/INetworkTaskCallback$Stub.class}
【发布时间】:2017-03-25 11:53:53
【问题描述】:

您好,我正在尝试构建 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'

【问题讨论】:

  • This post 可能会有所帮助
  • 好吧,让我投票以引起其他人的更多关注,以便您更快地回答

标签: java android firebase gradle apk


【解决方案1】:

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'

【讨论】:

  • 伙计,你救了我一整天来解决这个问题,非常感谢
  • 另一件需要考虑的事情:您同时使用旧版 Firebase SDK firebase-client-android:2.5.2 和新版 SDK com.google.firebase:firebase-messaging:10.2.1。这现在可能有效,但如果您继续从新 SDK 添加库,您可能会遇到冲突。 Upgrade Guide 是一个很好的资源。
  • 感谢您的观察,我应该删除哪个:firebase-client-android:2.5.2 或 com.google.firebase:firebase-messaging:10.2.1
  • 删除firebase-client-android:2.5.2。如果这会产生错误,请按照升级指南中的说明进行操作。
  • 我删除了 firebase-client-android:2.5.2 一切正常,谢谢你的帮助
猜你喜欢
  • 1970-01-01
  • 2023-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多