我试图为我的项目构建一个 apk,但我遇到了这个错误
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
block 引用>com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzajl;
我还添加了multiDexEnabled true,但仍然出现错误
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
block 引用>com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: 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'
然后清理重建并重新启动 IDE
。
关于java - 在 Android Studio 中构建 APK 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46605671/