Android : Unable to execute dex: Multiple dex files define Lorg/apache/cordova/App$1

on Friday, October 10, 2014


because of a high priority security fix in cordova for android we need to update our cordova version (from 2.7.0 to 3.6.3) in our app. So we thought it would be better to create a new project.


I installed cordova and create a project with cordova cli api. Also I added the android platform added many cordova plugins. Then I copied our sencha touch stuff into the www folder.


Then I called cordova build android.


After that I imported this android project in Android Studio (0.8.11).


For our app I needed to copy the following things from our old project



  • AndroidManifest.xml

  • All the stuff out of the res/ directory

  • in the src/ directory I added some stuff we need in our app


In our own written java files (src/ directory) everything was red. So we found out that in src/org.apache.cordova/ that there were only directories of the installed cordova plugins. So I downloaded cordova 3.6.X (from https://github.com/apache/cordova-android/tree/3.6.x) and copied all java files to src/org/apache/cordava.


Then I recognized that the android-support android-support-v13.jar library was missing in the lib/ folder. So I copied it out of the sdk\extras\android\support\v13 directory. After that nearly all red stuff in the code disappeared, so I tried to run it.


But I'm getting this error:



Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Develop\Android SDK\sdk\build-tools\19.1.0\dx.bat --dex --output D:\www\xxx\native\cordova-project\platforms\android\build\intermediates\dex\debug D:\www\DiLocSyncMobile\native\cordova-project\platforms\android\build\intermediates\classes\debug D:\www\xxx\native\cordova-project\platforms\android\build\intermediates\dependency-cache\debug D:\www\xxx\native\cordova-project\platforms\android\build\intermediates\pre-dexed\debug\android-support-v13-ba93a882b9b887c9c56ff93adba54cb3616bd827.jar D:\www\xxx\native\cordova-project\platforms\android\build\intermediates\pre-dexed\debug\classes-0236632443c0351e54fca9912536c8c02b5ad2b2.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/apache/cordova/App$1;
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)


My build.gradlefile is has got the following dependencies:



dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
for (subproject in getProjectList()) {
compile project(subproject)
}
}


In my lib/ directory is just the jar I added manually.


Please help me/ Thanks ahead!! :-)


0 comments:

Post a Comment