繁体   English   中英

app:dexDebug在build.gradle Android Studio中出错

[英]app:dexDebug error in build.gradle Android Studio

尝试在Android Studio上运行项目时,我收到app:dexDebug错误。 我相信这与我的依赖关系有关,但我不确定我要去哪里。

错误是:

错误:任务':app:dexDebug'的执行失败。

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\\ Program Files \\ Java \\ jdk1.7.0_17 \\ bin \\ java.exe'以非零退出值2

我对build.gradle文件的依赖关系如下:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
}

任何人都可以在这里指出正确的方向。

谢谢。

更新

通过将以下内容添加到我的build.gradle中来解决问题

packagingOptions {
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/NOTICE'
    }

Android Studio中Error:Execution failed for task ':app:dexDebug'来解决它设置multiDexEnabledtrue在你的文件的gradle。

defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
}

该问题很可能是由于添加了所有播放服务依赖项引起的。 您不应该将整个API包编译到您的应用中,否则会增加应用中方法的数量。 app:dexDebug错误指示您已超过65k方法限制。 在build.gradle中删除此行: compile 'com.google.android.gms:play-services:8.3.0'然后从这些单独的依赖项中进行选择,这些依赖项将根据您的应用程序的需要进行添加。 例如,要使用Gcm,您只需添加compile 'com.google.android.gms:play-services-gcm:8.4.0'

暂无
暂无

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

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