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.