3

My project can't compile with these libs:

enter image description here

My gradle code:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com...."
        minSdkVersion 9
        targetSdkVersion 21
        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'
}

Error:

**Error:Execution failed for task ':app:preDexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1**

user1468102
  • 391
  • 5
  • 16
  • I would suggest that you post the entire Gradle console output, as there may be more information there that we can use. You might also consider switching to repository artifacts for many of those dependencies, rather than using bare JARs. – CommonsWare Mar 22 '15 at 18:25
  • see this http://stackoverflow.com/a/31325884/1941569 – serabile Jul 09 '15 at 19:00

3 Answers3

1

The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex, so you have to add multiDexEnabled true to your gradle file like this :

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}
...
}

..

serabile
  • 329
  • 3
  • 11
0

Seems to be a problem with your library. Try to update it and use

compile 'com.android.support:appcompat-v7:22.0.0'
priyank
  • 2,651
  • 4
  • 24
  • 36
0

this error from Android Studio seems to occur when there are library files in our app/libs folder which are not yet included in the gradle build. user1468102's answer worked for me. I've emptied my libs folder and everything went well

Please this link as well for adding libraries to a project and with gradle

Community
  • 1
  • 1