2016-02-17 91 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(); 
}