Cocos compiled Android version encountered problem set in the same

Source: Internet
Author: User

Errors are as follows ... However, using Eclipse to build the APK package is not affected.

-dex:
[Dex] Input:e:\cocos\mine\frameworks\runtime-src\proj.android\bin\classes
[Dex] Input:e:\cocos\mine\frameworks\js-bindings\cocos2d-x\cocos\platform\android\java\bin\classes.jar
[Dex] Pre-dexing E:\cocos\Mine\frameworks\js-bindings\cocos2d-x\cocos\platform\android\java\bin\classes.jar Classes-022efb48739f8be18b60e7464733537d.jar
[Dex] converting compiled files and external libraries into E:\cocos\Mine\frameworks\runtime-src\proj.android\bin\ Classes.dex ...
[DX]
[DX] unexpected top-level EXCEPTION:
[Dx]com.android.dx.util.dexexception:multiple dex files define Lorg/cocos2dx/lib/cocos2dxaccelerometer;
[DX] at com.android.dx.merge.DexMerger.readSortableTypes (dexmerger.java:592)
[DX] at com.android.dx.merge.DexMerger.getSortedTypes (dexmerger.java:550)
[DX] at com.android.dx.merge.DexMerger.mergeClassDefs (dexmerger.java:531)
[DX] at com.android.dx.merge.DexMerger.mergeDexBuffers (dexmerger.java:168)
[DX] at Com.android.dx.merge.DexMerger.merge (dexmerger.java:186)
[DX] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers (main.java:300)
[DX] at Com.android.dx.command.dexer.Main.run (main.java:232)
[DX] at Com.android.dx.command.dexer.Main.main (main.java:174)
[DX] at Com.android.dx.command.Main.main (main.java:91)
[DX]

BUILD FAILED
E:\bst\adt-bundle-windows-x86-20130917\sdk\tools\ant\build.xml:892:the following error occurred while executing this Line
E:\bst\adt-bundle-windows-x86-20130917\sdk\tools\ant\build.xml:894:the following error occurred while executing this Line
E:\bst\adt-bundle-windows-x86-20130917\sdk\tools\ant\build.xml:906:the following error occurred while executing this Line
E:\bst\adt-bundle-windows-x86-20130917\sdk\tools\ant\build.xml:284:null Returned:2

---------------------------
Find out the data found that:
Cocos Compile's script will automatically "Frameworks\js-bindings\cocos2d-x\cocos\platform\android\java\bin\classes.jar" (2dx Java code) is added to Classes.dex.
When using Eclipse to open the Android project, the default is not to introduce 2DX Java class, at this time if you want to run Android project, need to introduce 2DX jar package, or introduce 2DX Java source code.
If the introduction of Java source Code, when the implementation of "Cocos compile", 2dx Java source code generated by the class file, with the default introduced "Frameworks\js-bindings\cocos2d-x \cocos\platform\ Android\java\bin\classes.jar "Conflict, will be reported" Com.android.dx.util.DexException:Multiple dex files define ... "error;
If you do not introduce Java source code, you introduce a jar package (located in the engine: Frameworks\js-bindings\cocos2d-x\cocos\platform \android\java\bin\) directly in the "Build path". Classes.jar), the Android project does not get an error, but when you use eclipse to build the APK package, you will find that the installation to the phone does not work because the 2DX files required by the project are not being scored into the APK. At this point, the corresponding jar package can be placed in the Android project's Libs directory (frameworks\runtime-src\proj.android\libs\), so that the generated APK package will work.
However, if you do this, and then perform "Cocos compile" again, you will find that the error is also reported, because the script will default to add files in the Libs directory to Classes.dex.

Sum up:
The above error occurs because the 2dx file was added repeatedly when using the "Cocos compile" script.
However, if I do this, using "Cocos compile" to compile the script (mainly because the script will copy the JS files and resources in the Android project), using Eclipse to package Android project APK, can ignore the above problem;


-------------Workarounds

Comment out the #android.library.reference.1= in the Project.Properties file. /cocos2d/cocos/platform/android/java can do it!!!

Cocos compiled Android version encountered problem set in the same

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.