0

I'm trying to debug my Android application but I'm getting the following error from gradlew assembleDebug:

AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]}
AGPBI: {"kind":"simple","text":"com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/plus/model/people/Person$AgeRange;","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_11\bin\java.exe'' finished with non-zero exit value 2

I've looked at past similar questions but was unable to find a solution. I think it has to do with my gradle files, as I just added some Google API stuff.

build.gradle for project:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.google.gms:google-services:1.3.0-beta1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle for module:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "com.zarwanhashem.ideatrackr"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.google.android.gms:play-services:7.5.0'
}

The only stuff that has been added to those files since my last successful debug is the Google stuff. I tried clean build, delete .gradle, and delete .idea.

EDIT: Here are the jars in my libs folder, in case some are conflicting: gdata-client-1.0.jar
gdata-client-meta-1.0.jar
gdata-core-1.0.jar
gdata-spreadsheet-3.0.jar
gdata-spreadsheet-meta-3.0.jar
google-play-services.jar
gson-2.2.4.jar
guava-18.0.jar

EDIT 2: After following the instructions in the comments below the error message changed to this:

Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/x.class

I went through my libs but was only able to find the gms directory in the google play jar so I don't know what it's conflicting with.

Zarwan
  • 5,537
  • 4
  • 30
  • 48
  • This error means you have the same library included twice. My initial guess is that you have a .jar in your libs that clashes with app compat or play services. But I don't have my Android Studio nearby to dbl check if you're correctly importing appcompat and or play-services. – Martin Marconcini Jul 25 '15 at 19:14
  • I edited them into my post. Do you see any conflicts? @MartínMarconcini – Zarwan Jul 25 '15 at 19:17
  • First you can include gson though gradle `compile 'com.google.code.gson:gson:2.3.1'` (replace with the latest version, I think it's that one). Then I see you have google-play-services.jar there as well, that may be your problem. Check https://developers.google.com/android/guides/setup to make sure you're adding play services the correct way. – Martin Marconcini Jul 25 '15 at 19:32
  • I don't know about the gdata ones… make sure they don't conflict with each other. – Martin Marconcini Jul 25 '15 at 19:32
  • Guava can also be gradle'd: `compile group: 'com.google.guava', name: 'guava', version: '18.0'` (source: https://code.google.com/p/guava-libraries/wiki/UseGuavaInYourBuild) – Martin Marconcini Jul 25 '15 at 19:34
  • That is the page I was following actually, and I changed the jars, thanks. I went though the gdata jars and I don't think they conflict. @MartínMarconcini – Zarwan Jul 25 '15 at 19:42
  • i have this issue earlier i solved it by reducing google play service version to compile 'com.google.android.gms:play-services:6.1.71' and seting and set multiDexEnabled = true in default config of gradle see this link http://stackoverflow.com/questions/28640314/android-studio-fails-to-debug-with-error-org-gradle-process-internal-execexcepti?answertab=votes#tab-top – sachithkn Jul 25 '15 at 20:25
  • Did it work this time? – Martin Marconcini Jul 25 '15 at 20:26
  • The error message changed to "...ZipException: duplicate entry: com/google/android/gms/internal/x.class". I went through the other libs though and I only found that gms directory in the google play jar so idk what it's conflicting with @MartínMarconcini – Zarwan Jul 26 '15 at 22:31
  • I posted a new question because the information has changed: http://stackoverflow.com/questions/31642819/android-google-play-services-duplicate-entry @MartínMarconcini – Zarwan Jul 26 '15 at 23:05

1 Answers1

0

I think you migrate from eclipse to AS and you have still in your folder libs the

android-support-v4.jar --> delete it

and it should work

lukas
  • 495
  • 4
  • 13