2017-02-21 81 views
0

我創建了一個應用程序與谷歌服務,現在我想要生成一個簽名的apk。但是,當我嘗試創建這個APK我得到這個錯誤TransformException多個dex文件

Error:Execution failed for task ':app:transformClassesWithDexForRelease'. 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/zzqv;

這是我的搖籃文件

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 25 
buildToolsVersion "25.0.0" 
defaultConfig { 
    applicationId "com.xxx.xxx.xxx" 
    minSdkVersion 18 
    targetSdkVersion 25 
    versionCode 5 
    versionName "2.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

} 
buildTypes { 
    release { 
     minifyEnabled false 
     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.1.0' 
compile project(':BaseGameUtils') 
compile 'com.google.android.gms:play-services-ads:10.2.0' 
compile 'com.google.android.gms:play-services-games:10.2.0' 
compile 'com.google.android.gms:play-services-gcm:10.2.0' 
compile 'cn.pedant.sweetalert:library:1.3' 
compile 'com.nineoldandroids:library:2.4.0' 
compile 'com.daimajia.easing:library:[email protected]' 
compile 'com.daimajia.androidanimations:library:[email protected]' 
testCompile 'junit:junit:4.12' 
} 

我試圖從一些#1解決方案,但我依然出現。

我希望你們能幫助我解決我的問題

回答

0

嘗試啓用multidex中的build.gradle:

defaultConfig { 
    ... 
    multiDexEnabled true 
} 

同時添加的依賴關係:

dependencies { 
    compile 'com.android.support:multidex:1.0.0' 
} 

現在,在您的應用分類:附加multidex

public class MyApplication extends Application { 

    @Override 
    protected void attachBaseContext(Context base) { 
     super.attachBaseContext(base); 
     MultiDex.install(this); 
    } 

} 

請確保您在清單中定義了應用程序類

+0

感謝您的快速評論。我嘗試了你的建議,現在我得到以下錯誤:'錯誤:執行失敗的任務':app:transformClassesWithJarMergingForRelease'。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重複條目:com/google/android/gms/internal/zzqv.class' – user5985727

+0

clean build the project .. if the problem still出現嘗試這種解決方案:你有重複的條目http://stackoverflow.com/questions/26966843/java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult – rafsanahmad007

+0

謝謝你爲我工作 – user5985727

相關問題