mixpanel / mixpanel-android

Official Android Tracking Library for Mixpanel Analytics
http://mixpanel.com/
Apache License 2.0
1.02k stars 365 forks source link

Error:Execution failed for task ':app:dexDevDebug'. #187

Closed younes0 closed 9 years ago

younes0 commented 9 years ago

My app building process was working fine until I've included this SDK, I get this error:

Error:Execution failed for task ':app:dexDevDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: E:\Programs\Android SDK\build-tools\21.1.2\dx.bat --dex --no-optimize --output E:\android\bnm\app\build\intermediates\dex\dev\debug --input-list=E:\android\bnm\app\build\intermediates\tmp\dex\dev\debug\inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106)

These are my depencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // google
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:recyclerview-v7:21.0.0'
    compile 'com.google.guava:guava:18.0'
    // analytics
    compile 'com.mixpanel.android:mixpanel-android:4.5.3'
    // framework
    compile 'com.jakewharton:butterknife:6.0.0'
    compile 'com.squareup.dagger:dagger:1.2.2'
    provided 'com.squareup.dagger:dagger-compiler:1.2.2'
    compile 'ru.noties:debug:1.1.1'
    compile 'commons-lang:commons-lang:2.6'
    // other
    compile 'com.github.polok.taggerstring:library:1.0.0'
    compile 'com.koushikdutta.ion:ion:2.0.1'
    compile 'com.lorentzos.swipecards:library:1.0.7@aar'
    compile 'me.alexrs:prefs:1.0.3'
    compile 'it.neokree:MaterialNavigationDrawer:1.2.9'
    compile 'com.jpardogo.materialtabstrip:library:1.0.8'
    compile 'com.twotoasters.SectionCursorAdapter:library:2.0.+'
    compile 'com.github.machinarius:preferencefragment:0.1.2'
    compile 'com.pnikosis:materialish-progress:1.4'
    // testing
    testCompile 'junit:junit:4.10'
    testCompile 'org.robolectric:robolectric:2.4'
}
joeatwork commented 9 years ago

It looks like you've hit the method limit for your app. You may need to proguard it, or build it with multiple dex files. If you do proguard it, please include the following in your proguard file:

-keep class com.mixpanel.android.abtesting.** { *; }
-keep class com.mixpanel.android.mpmetrics.** { *; }
-keep class com.mixpanel.android.surveys.** { *; }
-keep class com.mixpanel.android.util.** { *; }
-keep class com.mixpanel.android.java_websocket.** { *; }

-keepattributes InnerClasses

-keep class **.R
-keep class **.R$* {
<fields>;
}
younes0 commented 9 years ago

I didn't think that I was going to reach that limit so quickly. I could build the proguard version with this SDK. Thanks @joeatwork !