Error while running project from eclipse

i have downloaded cocos2d x v3.3 beta and created a project in windows using this command

cocos.py new Tutorialv3cocos -p com.ghostdreamstudo.learning -l cpp -d D:\Development\Learning

Then i have imported project to eclipse and tried to run but eclipse gives me following error

[2014-10-03 18:40:39 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/cocos2dx/lib/Cocos2dxAccelerometer;
[2014-10-03 18:40:39 - Tutorialv3cocos] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/cocos2dx/lib/Cocos2dxAccelerometer;

Does anyone face the same problem or know how to solve this issue??

Same issue. I did not experience this with 3.2. I created a new project in 3.3rc0 and encountered the same error with a bare-bones project.

using cocos run from the command line instead of Eclipse is successful and the default app launches on my android phone:

cocos run -s [path]/[app name] -p android

I figured out how to get new projects to build without Multiple dex files… errors using Cocos2d-x v.3.3rc0

Here’s the error you may get to start with:
The container ‘Android Dependencies’ references non existing library ‘[your path]/cocos2d/cocos/platform/android/java/bin/libcocos2dx.jar’ [your project name] Build path Build Path Problem

If you don’t have Build Automatically selected in the Eclipse settings, your libcocos2dx project won’t build the necessary libcocos2dx.jar binary. Turn on Build Automatically, or just click Project > Build Project for the libcocos2dx project.

Now you can build the main project, but you may see these errors:

[2014-11-19 00:48:32 - libcocos2dx] Unable to resolve target ‘android-10’
[2014-11-19 00:48:38 - test2] Unable to resolve target ‘android-10’
[2014-11-19 00:52:55 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/cocos2dx/lib/Cocos2dxAccelerometer;
[2014-11-19 00:52:55 - test2] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/cocos2dx/lib/Cocos2dxAccelerometer;

right-click the project and go into Properties dialog > Android > Library pane. remove the link to libcocos2dx. This seems to be different from Cocos2d-x v.3.2.

Now you can run build_native.py and then run the app without errors.

My system:
Mac 10.9.4
Cocos2d-x v.3.3rc0

1 Like

Worked for me with the example project. Took so long rebuilding for both (my AVD’s) x86 and arm ABI’s that I thought I’d better post before I forget more of what worked. Need to remember what the example had my real project didn’t. And. not. play. hungry. shark.

I’ve been building in Cocos2dx for iTunes for a little while, but had never built for Google/Android. I had this exact error for a few weeks, and had to solve a few problems in order to solve this problem, which led to a few more problems. I now have my apps running correctly on Android, so I wanted to include a few of the key steps:

First, the “Multiple Dex” issue was actually being caused by an error much earlier on, but because LOGCAT was set to 5,000 lines, the ACTUAL error was scrolling off the top of the buffer and getting dumped out. Turned LOGCAT up to 10,000 lines.

On a rebuild, long before the pile of DEX errors (which I tried fixing by checking and unchecking and cleaning and a ton of other advice from other forums), was a “folder not found” error. Specifically, it was looking for a folder named “mips” in a number of /Cocos2d/external/prebuilt subfolders. I opened one of them up (freetype2 was the first one causing the error), and saw that it did not in fact have a “mips” folder, but it DID have an “armeabi”, “armeabi-v7a”, and “x86” folder.

Inside the file /proj.android/jni/Application.mk on the 3rd line, it was specifying to build in “mips”. I changed this to APP_ABI:=armeabi-v7a so it can find all these libraries correctly.

Next, for some reason even though my Cocos setup and bash profile include the NDK location, Eclipse was unable to find it. I fixed that by going to /proj.android/build_native.py, and on the lines where it says SDK_ROOT and NDK_ROOT =, I defined them explicitly like this:

    NDK_ROOT = '/Users/myusername/Desktop/apps/android-ndk-r9d'
    SDK_ROOT = '/Users/myusername/Desktop/apps/adt-bundle-mac-x86_64-20140702/sdk'

Last step is to go into /proj.android/jni/Android.mk and make sure all your resources are listed. I don’t understand this part well, but I fixed this by just listing all my .cpp files like this:

LOCAL_SRC_FILES := hellocpp/main.cpp
…/…/Classes/AppDelegate.cpp
…/…/Classes/GoodbyeWorldScene.cpp
…/…/Classes/LoadingScreen.cpp
…/…/Classes/MarketScene.cpp
…/…/Classes/MySingleton.cpp
…/…/Classes/TitleScene.cpp
…/…/Classes/HelloWorldScene.cpp

After that, one final issue is that it should have been in portrait mode, which I had to set manually in “AndroidManifest.xml”

Last issue is that Android doesn’t seem to be able to handle “aiff” files, so I needed .wav versions of all my sounds.

Once all that was done, I went directly to the proj.android/ folder in Terminal and built it with “python build_native.py” and it did a complete rebuild.

There are probably “better” solutions to most of these problems, but I am now happily playing my app on my Android phone and iPhone.