-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

希望这会帮助您解决您的问题。

相关问题