-5

我在我的build.gradle文件中添加下面的依賴實現GCM:錯誤:執行任務':app:dexDebug'失敗。

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

但是,漸漸以下錯誤:

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

我builg.gradle文件如下:

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.1.1' 
//Dependency To hangle OKHTTP Operations 
compile 'com.squareup.okhttp:okhttp:2.6.0' 
//Dependency To Generate QRcode (Dependency to hangle QRcode libraries) 
compile 'com.google.zxing:core:2.2' 
compile 'com.embarkmobile:zxing-android-minimal:[email protected]' 
compile 'com.google.android.support:wearable:1.1.0' 
//Dependency To hangle Scanning of QRCode 
compile 'me.dm7.barcodescanner:zxing:1.8.3' 
//Dependency To hangle Piccaso library 
compile 'com.squareup.picasso:picasso:2.5.0' 
//Multipart depency 
// compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' 
compile('org.apache.httpcomponents:httpmime:4.3') { 
    exclude module: "httpclient" 
} 
compile 'com.android.support:cardview-v7:23.0.+' 
//To make imageview round cornered 
compile 'com.makeramen:roundedimageview:2.2.1' 
compile 'com.itextpdf:itextpdf:5.5.8' 
compile 'com.google.android.gms:play-services:7.8.0' 
} 
+1

請檢查這個答案(http://stackoverflow.com/questions/18021901/android-studio-gradle-build-fails-execution-failed-for-task-dexdebug) –

+1

在你的內部使用「multiDexEnabled true」 「defaultConfig」然後編譯 –

+0

@RakshitNawani已添加但仍然出現錯誤 – user5716019

回答

0

看着你的項目的gradle文件,我認爲你面臨的問題沒有方法約束(這是65536)強加給谷歌。

您需要從源代碼中刪除不需要的庫,或者您可以爲您的項目創建MultiDex文件。

要啓用multidex文件做你的gradle這個文件中的以下變化,

defaultConfig { 
     minSdkVersion 14 
     targetSdkVersion 14 
     // Enabling multidex support. 
     multiDexEnabled true 
    } 

並創建應用程序類擴展應用程序,並把下面的代碼段,

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

你可以參考以下鏈接以獲得更多參考和信息。 http://developer.android.com/tools/building/multidex.html

希望這會幫助您解決您的問題。

相關問題