Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio execution failed for task- process exception for idk-1.8

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.

like image 436
beginnerCoder Avatar asked Jun 15 '15 19:06

beginnerCoder


2 Answers

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.

like image 57
nmw Avatar answered Nov 09 '22 23:11

nmw


Try clicking on File > Invalidate caches / Restart > Invalidate and Restart. Once it builds, run your project again. It worked for me.

like image 41
user2331595 Avatar answered Nov 09 '22 22:11

user2331595