【问题标题】:Error during Building an APK file in Android Studio在 Android Studio 中构建 APK 文件时出错
【发布时间】:2017-10-06 12:23:17
【问题描述】:

我试图为我的项目构建一个 apk,但我遇到了这个错误并且

错误:任务执行失败 ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:com.android.dex.DexException: 多个dex文件定义Lcom/google/android/gms/internal/zzajl;

我还添加了 multiDexEnabled true 但仍然出现错误

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

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

下面是我的 Build.gradle 文件

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "in.package.name"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true


    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            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 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-ads:11.0.1'
    testCompile 'junit:junit:4.12'
    // Adding support library for this demo app
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.firebase:firebase-database:9.6.1'


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

请给我一些解决方案 谢谢

【问题讨论】:

    标签: java android


    【解决方案1】:

    使用 SAME 版本

    compile 'com.google.android.gms:play-services-ads:11.0.1'
     compile 'com.google.firebase:firebase-database:11.0.1'
    

    然后Clean-Rebuild and Restart IDE

    【讨论】:

    • 单独的问题(虽然它也是一个问题)。重复的 zip 文件通过清理和重建修复
    • 我接受了,但早些时候它说等待 8 分钟你不能立即接受
    • @AyushRawat 是的。那里有时间验证。
    【解决方案2】:

    先尝试清理项目 - ./gradlew clean

    【讨论】:

      猜你喜欢
      • 2022-10-25
      • 1970-01-01
      • 2017-09-27
      • 1970-01-01
      • 2020-04-24
      • 2016-12-08
      • 1970-01-01
      • 2018-09-28
      • 2020-03-10
      相关资源
      最近更新 更多