2013-12-12

Setup Android Project on Cocos2d-x 3.0

Important things need to make cocos2d-x android project running

1. Make sure the Android SDK (ADT) and NDK ready 


2. Configure the Android.mk 


Need to config the following variables:

  • LOCAL_SRC_FILES : Because we may have more sources than the "HelloWorld" project
  • LOCAL_C_INCLUDES: The related header files will be searched by the compiler
  • LOCAL_WHOLE_STATIC_LIBRARIES: Our project may not need the sdk given
  • $(call import-module, moduleName) : Need to match with the LOCAL_WHOLE_STATIC_LIBRARIES


3. Configure the AndroidManifest correctly 

Need to config these two variables:

  • <uses-sdk android:minSdkVersion="9"/>  : Need to "9" or above to use Native Activity
  • <meta-data android:name="android.app.lib_name" android:value="App" /> : it will link to your native library called "libApp.so"

4. Copy the java source to proj.android

5. Prepare Eclipse to import the android project


Other Troubleshooting

Unable to load native library: "xxx.so"

Problem: Fail to define the native library
Solution: config the library name correctly in AndroidManifest.xml

For example: your library is libs/armeabi/libGame.so
the value defined in AndroidManifest.xml should be like the following:
<meta-data android:name="android.app.lib_name" android:value="Game" /> 
Note: No need to define the path, extension, and 'lib' prefix;

LogCat said "dvmFindClassByName rejecting 'org/cocos2dx/lib/Cocos2dxHelper"

Problem: Missing the java source folder
Solution:  http://www.cocos2d-x.org/forums/6/topics/36265

No comments:

Post a Comment