简体   繁体   中英

Android gradle app:DexDebug error Parse.com

I have build an android app and i have this error when trying to compile my app

Error:Execution failed for task ':app:dexDebug'.>com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

This is my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId ********
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 5
        versionName "1.211"
       // multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories { mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile fileTree('src/main/libs')
    compile fileTree('src/main/libs/picasso-2.5.2.jar')
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
    compile('com.twitter.sdk.android:twitter:1.12.0@aar') {
        transitive = true;
    }
    compile 'com.parse:parsetwitterutils-android:1.10.+'
}

It says on parse.com that "Add compile 'com.parse:parsetwitterutils-android:1.10.+' to your Gradle dependencies. This includes the contents of the Parse-*.jar and the com.parse:parse-android:1.10.+ repository, so be sure to remove as needed to prevent duplicate dependencies, otherwise a com.android.dex.DexException will be thrown."

and in my library i have

bolts-android-1.2.0.jar
Parse-1.9.4.jar
picasso-2.5.2.jar
commons-io-2.4.jar

EDIT: when i enable multiDex in gradle i get this error

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.> java.util.zip.ZipException: duplicate entry: bolts/AggregateException.class

when i comment this line out compile 'com.parse:parsetwitterutils-android:1.10.+' all works well

i am not sure how to get rid of the error being thrown when i add the above line can some one please help.

Replace this:

compile 'com.facebook.android:facebook-android-sdk:4.6.0'

with:

compile ('com.facebook.android:facebook-android-sdk:4.6.0') {
    exclude module: 'bolts-android'
}

I guess you need to improve a multidex in your code, just add

    compile 'com.android.support:multidex:1.0.0' 

in your gradle file and in your application attachBaseContext just put MultiDex.install(this) like this

    @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

I forgot, you need to add

 multiDexEnabled true

in your gradle file too

hope it can help you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM