I find it difficult to integrate the Twitter Fabric SDK into my application. I followed the twitter steps and everything was fine, but when I try to build my project using gradle, I get this error:
Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.internal.LoggedErrorException: Failed to run command: D:\Android\android-studio\sdk\build-tools\android-4.4W\dx.bat --dex --output ... Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/google/gson/JsonSerializer; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) at com.android.dx.command.dexer.Main.run(Main.java:230) at com.android.dx.command.dexer.Main.main(Main.java:199) at com.android.dx.command.Main.main(Main.java:103)
I tried to remove my static Gson library from the folder of my application module, and after that everything went well. Same thing when deleting a line that adds twitter sdk from the dependencies of the gradle module, so I'm sure there is some conflict between these two conflicts, and I'm looking for it.
Any help would be greatly appreciated!
In case this can be useful for people, here is my gradle file of the application module:
apply plugin: 'com.android.application' apply plugin: 'io.fabric' android { ... buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { signingConfig signingConfigs.debug ext.enableCrashlytics = false } } } repositories { jcenter() mavenCentral() maven{ url 'https://maven.fabric.io/repo'} } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':facebook') compile 'com.android.support:support-v13:20.0.0' compile 'com.google.android.gms:play-services:6.1.11' compile('com.twitter.sdk.android:twitter: 1.0.0@aar ') { transitive = true; } }
android gson twitter gradle fabric-twitter
user3476114
source share