Hi I am just trying to use the Card IO and Braintree Android SDK in one Android Project using Android Studio with Gradle build of course. I haven't even add any code referencing these 2 libraries yet. I just set them as dependency in the gradle build file as shown below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "blahblahblah"
minSdkVersion 10
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
......
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':android-async-http-1.4.6')
compile project(':gson-2.3.1')
compile project(':card.io')
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:support-v4:21.0.2'
compile 'com.braintreepayments.api:braintree:1.+'
}
Then I tried a clean and build which succeed but when I try to run it on the testing phone i received the following :
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Applications/ADT_Bundle/sdk/build-tools/21.1.1/dx --dex --no-optimize --output /path_to_project_root/app/build/intermediates/dex/debug --input-list=/path_to_project_root/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lio/card/payment/b;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
I tried deleting everything under
app/build/generated, outputs and temp
and even invalid Android Studio cache and restart. No good. What this looks like to me is that something that both Card IO and Braintree Android SDK has and they both are about to be packed into the apk. Does Braintree Android SDK included Card IO already or something ?
Can anyone point out where I did wrong ? Many many thanks !
The Braintree SDK already includes the cardio java classes. However, it does not include the .so files. Please try removing your local copy of card.io.jar, and everything should work.