Reputation: 21
i need to do more graph in my app and i thought to import that library ( http://www.android-graphview.org/ ).
I just follow the rules and i add to the gradle the compile row.
That is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.btc.btcmobile"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.jjoe64:graphview:4.0.0'
}
after that, i copy-paste the example on the site, but when i compile now i can see that error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\Users\valerio\AppData\Local\Android\sdk2\build-tools\21.1.1\dx.bat --dex --no-optimize --output C:\Users\valerio\Desktop\BtcMobile\btcmobile\app\build\intermediates\dex\debug --input-list=C:\Users\valerio\Desktop\BtcMobile\btcmobile\app\build\intermediates\tmp\dex\debug\inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lcom/jjoe64/graphview/BuildConfig; 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) UNEXPECTED TOP-LEVEL EXCEPTION:
How i can resolve?
Thanks.
Upvotes: 1
Views: 969
Reputation: 867
In my case I had the GraphView4.1.jar inside the libs folder. I also had compile 'com.jjoe64:graphview:4.0.1' in the build.gradle. As soon as I removed the jar file from libs folder, the com.android.dex.DexException error was resolved.
Upvotes: 1