I can't seem to fix this error after I add a jar file to the project:
Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
The program runs without the jar file but when I add it, everything builds but it gives me this error when I try to run it. I have searched and tried the following solutions but nothing fixed the error.
why java.exe exit with value 1 in android studio
Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2
Android java.exe finished with non-zero exit value 1
Since none of these solutions worked I thought it my be a over 65k method problem so I edited my build.gradle but the problem still exists.
https://developer.android.com/tools/building/multidex.html
This is my build.grade for my app project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
................
minSdkVersion 15
targetSdkVersion 21
multiDexEnabled = true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:multidex:1.0.0'
compile files('libs/xyz.jar')
}
I don't know how to fix this problem. Any help would be appreciated.
I had this error message (also only when running not building) when attempting to add a plain Java module as a dependency on an Android module. Though it only happened in Android Studio, not from the command line.
I solved it by including the following line in the plain Java module's build.gradle:
sourceCompatibility = 1.7
Note that Android Studio marks this line as not used.
Try clicking on File > Invalidate caches / Restart > Invalidate and Restart. Once it builds, run your project again. It worked for me.
I guess this has to do with the number of libraries you are including in your project. Although I am not certain this will help you could put this in your gradle file:
defaultConfig {
...
multiDexEnabled true
}
But even with that I got this error after adding another library. I was lucky that one lib was not crucial for the app, it was a library for catching memory leaks, so I removed it and then it compiled. As I am not an expert here maybe someone can add something to this topic? I will try to find out more about this 65k limit and how to overcome it and will get back to this.
I resolved this error by switching the JDK location of my android studio project. Just right click on the project root directory select Open Module Settings, under the sdk location option, browse the JDK location to a different one if you have 2 or more installation as in my case there were:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
and
/Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home
For me, I open SDK Manager, and update all the package that could be updated, and restart my MacBook, then it works.
I am wondering if it relevant with my updated OSX, coz I updated it to 10.10.4 yesterday, my project was good but crashed after, anyway, try to update all the things you could do, even re-install java.
Good luck!
The error comes from you running a Java 8 SDK instead of a Java 7 SDK (which at the time of this writing seems to be required for Android Studio).
I installed Java 7 from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and pointed Android Studio to use the Java 7 JDK by going to File > Other Settings > Default Project Structure... (Android Studio 1.3)
Now everything works just fine!