Utilizing c++ libraries and the NDK on android

Hello Community!,

First of all, I would like to mention that I am completely new to Android development. While I know the Java language fairly well, I have not done any android development yet and therefore have little understanding of it.

I have sifted through the forums and source code, but I seem to be unable to find the answers to the following questions:

  1. For the Android cocos2d-x build, where is the build process started? What file actually STARTS the initiation/running of the cocos2dx application on the android phone?
  2. Is any of the Cocos2dx c++ code actually run and compiled for the android system through the NDK, or is all of the C++ code simply wrapped into java classes that then run on the android?
  3. I want to use a udp networking library called eNet in my game. I am wondering if directly utilizing the library through the NDK will be compatible with all android systems, and whether or not I will be able to package the app into an .APK for the Google Play Store.
  4. IF I cannot use eNet with it’s c++ code, then I’ll have to port some parts or all of it into Java code. How would I call the eNet Java code from within my application considering cocos2d-x is written using c++, and I only want to call the Java code if it is running on the Android?

If you have any links that might enlighten me, it’d be highly appreciated. I am quite lost and perhaps some of the confusion comes from my lack of understanding the NDK/NJI.

Thank you!

I compiled the code and noticed armeabi.


http://www.cocos2d-x.org/wiki/Build_HelloWorld_on_android_x86_platform
So it looks like I CAN simply use the c++ library, I will just have to compile a couple different .APK files for only a few different CPU structures. Seems manageable enough.

Android make files and the like are still completely new territory, but it seems easy enough:
http://www.cocos2d-x.org/wiki/Build_HelloWorld_on_android_x86_platform

  1. When cocos2d-x starts on Android, Cocos2dxActivity is the Main Activity, but usually you will create a derived class such as AppActivity and mark it as start activity in the AndroidManifest.xml
  2. in Cocos2dxActivity there is a function onLoadNativeLibraries that’s when C++ code gets loaded. For C++ the entry point should be here
  3. For C++ libraries, you should check the documentation, and see if it works with android
  4. Usually networking code depends on curl, which is included with cocos2d-x there is a good chance it will work.