Adding custom jar dependency to module in android studio Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Adding custom jar dependency to module in android studio without wasting too much if your time.

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’. 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: ''

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'), ''
    productFlavors {

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile ''
    compile ''
    provided files('libs/MyJar.jar')

any suggestions?


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.


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')
We are here to answer your question about Adding custom jar dependency to module in android studio - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji