The question is published on by Tutorial Guruji team.
I have an android project contains a module.
I added a library named lib to the project, then I added a jar (jar I have created in an other project).
then clicked file –> project structure –> choose my module –> dependencies –> added a jar dependency.
When I try to create the apk I get the following error:
Execution failed for task ‘:app:preDexDebug’. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:Program FilesJavajdk1.8.0_60binjava.exe” finished with non-zero exit value 1
I have tried to change the scope dependency to provided, which did not helped,
Also I have tried to create new module the have a dependency in the jar, that did not work.
my build.gradle:
apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "23.0.1" defaultConfig { applicationId "com.myprj" minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:support-v4:22.2.0' 'com.sun.jersey:jersey-client:1.18.1' 'com.sun.jersey:jersey-json:1.18.1' 'org.codehaus.jackson:jackson-jaxrs:1.1.1' 'com.owlike:genson:0.99' provided files('libs/MyJar.jar') }
any suggestions?
UPDATE
I solved my problem, the other jar was compiled with java 1.8 settings, I changed it to 1.7 and recreated the jar, that solved my problem.
Answer
Remove this line:
provided files('libs/MyJar.jar')
You’re already including every .jar in libs directory a couple of lines above:
compile fileTree(include: ['*.jar'], dir: 'libs')