繁体   English   中英

在Android Studio中构建APK文件时出错

[英]Error during Building an APK file in Android Studio

我正在尝试为我的项目构建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 /克/内部/ 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'

请给我建议一些解决方案,谢谢

使用相同版本

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

尝试先清理项目./gradlew clean

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM