【问题标题】:App:transformClassesWithJarMergingForDebug FAILED duplicate entry应用程序:transformClassesWithJarMergingForDebug FAILED 重复条目
【发布时间】:2017-05-03 20:30:21
【问题描述】:

美好的一天,我正在做 FireBase 云通知,我会得到 ​​p>

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

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/common/api/zza.class

分级

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "aminfocraft.harsh.firebasenotificationdemo"
        minSdkVersion 15
        multiDexEnabled true
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.1'
    apply plugin: 'com.google.gms.google-services'
    compile 'com.google.firebase:firebase-messaging:10.2.1'
}

./gradlew clean 也不行

【问题讨论】:

    标签: android android-studio android-gradle-plugin


    【解决方案1】:

    问题1

    致电apply plugin properly

    问题2

    添加play-services:10.2.1

    试试这个方法

     apply plugin: 'com.android.application'
     apply plugin: 'com.google.gms.google-services'
     android {
        compileSdkVersion 25
        buildToolsVersion "25.0.2"
    
        defaultConfig {
            applicationId "aminfocraft.harsh.firebasenotificationdemo"
            minSdkVersion 15
            multiDexEnabled true
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
        dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.google.android.gms:play-services:10.2.1'
        compile 'com.google.firebase:firebase-messaging:10.2.1'
    }
    

    【讨论】:

      【解决方案2】:
      apply plugin: 'com.google.gms.google-services'
      

      应该在依赖项之外

      dependencies {
          compile fileTree(dir: 'libs', include: ['*.jar'])
          testCompile 'junit:junit:4.12'
          compile 'com.android.support:appcompat-v7:25.3.1'    
          compile 'com.google.firebase:firebase-messaging:10.2.1'
          }
      
       apply plugin: 'com.google.gms.google-services'
      

      【讨论】:

        【解决方案3】:

        这个:

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

        应该在dependencies之外

         dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            testCompile 'junit:junit:4.12'
            compile 'com.android.support:appcompat-v7:25.3.1'    
            compile 'com.google.firebase:firebase-messaging:10.2.1'
            }
        
         apply plugin: 'com.google.gms.google-services' 
        

        另外你忘了添加播放服务依赖..

        添加compile 'com.google.android.gms:play-services:10.2.1'

        【讨论】:

          【解决方案4】:
          apply plugin: 'com.google.gms.google-services'
          

          应该在依赖项之外

           dependencies {
              compile fileTree(dir: 'libs', include: ['*.jar'])
              testCompile 'junit:junit:4.12'
              compile 'com.android.support:appcompat-v7:25.3.1'    
              compile 'com.google.firebase:firebase-messaging:10.2.1'
              }
          
           apply plugin: 'com.google.gms.google-services'
          

          你也忘了添加播放服务依赖项.. 添加

          compile 'com.google.android.gms:play-services:10.2.1'

          【讨论】:

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