我正在尝试使用我的三星/虚拟机编译我的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 :(得分:0)
尝试在您的gradle中启用multi dex文件支持。
将以下代码添加到build.gradle
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
答案 1 :(得分:0)
据我所知,此错误与JDK或gradle本身无关,可能有很多原因,例如:
您可以尝试在gradle中启用multi dex支持:
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
或者只是尝试通过删除一些不必要的库来最小化应用程序。
对于Android Studio中的此运行跟随命令:
gradlew -q dependencies yourProjectName_usually_app:dependencies --configuration compile
在列出的依赖项中搜索重复项(标有星号*)并将其删除。
在this问题中列出了更多可能性。
答案 2 :(得分: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
}
清理代码并重新构建
答案 3 :(得分: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();
}