2016-02-17 30 views
0

我试图用我的三星/虚拟机编译我的Android项目,但我得到以下错误:Android应用程序不会推出

Error:Execution failed for task ':app:dexDebug'. 
    > com.android.ide.common.process.ProcessException:   
    org.gradle.process.internal.ExecException: Process 'command 
    '/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java'' 
    finished with non-zero exit value 2 

我不能请在任何地方找到答案,请任何想法?

+0

什么是你正在使用的库? – zackygaurav

回答

0

尝试在您的gradle中启用多个dex文件支持。

添加下面的代码到你的build.gradle

defaultConfig {   
    // Enabling multidex support. 
    multiDexEnabled true 
} 
0

据我所知,这个错误是不相关的JDK或摇篮本身,可能有很多原因,如:

  1. 超过65k的方法限制。

你可以尝试的gradle中实现多DEX支持:

defaultConfig {   
    // Enabling multidex support. 
    multiDexEnabled true 
} 

或者只是通过删除一些不必要的图书馆,以尽量减少应用程序。

  1. 某些jar或库文件包含在几个地方。

就该运行而言,以下Android Studio中的命令:

gradlew -q dependencies yourProjectName_usually_app:dependencies --configuration compile 

搜索中列出的依赖重复(标有星号*),并删除它。

this问题有更多的可能性列出。

0
classpath 'com.android.tools.build:gradle:1.3.0' -> Should be 1.3.1 

buildToolsVersion '23.0.0' -> Should be '23.0.2' 

另外补充

defaultConfig {   
// Enabling multidex support. 
multiDexEnabled true 

}

清理你的代码,并再次建立

+0

其伟大!但我的成绩版本目前是1.1.0,我该如何更新它? – Sam

+0

使用sdk管理器更新您的sdk。之后,您可以选择将其更改为最新版本。 –

0
For me the problem was, i had put a unnecessary compile library code in build.gradle 

dependencies { 
    compile 'com.google.android.gms:play-services:7.5.0' 
} 
which was causing over 65k methods, so removed it,gradle sync, cleaned project, and then ran again and then this error stopped. I needed just maps and gcm so i put these lines and synced project 

compile 'com.google.android.gms:play-services-gcm:7.5.0' 
compile 'com.google.android.gms:play-services-location:7.5.0' 

Hi people i again encountered this problem and this time it was because of changing build tools version and it really required me to enable multidex..so i added these my app's build.gradle file.. 

defaultConfig { 
    applicationId "com.am.android" 
    minSdkVersion 13 
    targetSdkVersion 23 
    // Enabling multidex support. 
    multiDexEnabled true 
} 

dexOptions { 
    incremental true 
    javaMaxHeapSize "2048M" 
    jumboMode = true 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:multidex:1.0.1' 
} 
And create a class that extends Application class and include this method inside the class.. 

@Override 
protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this); 
} 
also include in OnCreate method too 

@Override 
public void onCreate() { 
    MultiDex.install(this); 
    super.onCreate(); 
}