Xiaomeng Ye
Xiaomeng Ye

Reputation: 11

cocos2dx: from win32 project to android project

Sorry it's my first time with cross-platform programming and I spent 4 hours for naught this afternoon.

I currently have a cocos2dx win32 project. I can run it on Visual Studio. My mentor told me to find a way to convert it to an android project. I have followed the instructions to set up the android environment, so I have: the recommended ADT (modified eclipse), NDK, and cygwin. Honestly I do not really know what NDK and cygwin is for. I have never played with linux either. Is there an informative page for how they work? All the pages I found are how-to-set-up-environment.

I think I set up the environment just ok, because I built a default helloworld project and ran it on the ADK emulator. However, I find no way to convert the win32 project I have to an android project.

I also found that in the folder of my project there is a .bat file called create-android-project.bat. And I followed some instructions from online to set up the three parameters for this batch file: the package path, project name, and target id. However the batch failed with errors like "No such file or folder...". I tested with other win32 projects I have. Ended up with similar errors.

Interestingly, if I ran this batch in the original cocos2dx project (the one with samples, templates, and built multi-platform projects), the batch ran just fine.

I really don't know what to do now. Can any one give me a solid guide page on this? Thanks a lot!

Upvotes: 0

Views: 710

Answers (3)

einverne
einverne

Reputation: 6682

I have successfully converted my Cocos2d-x 2.1.5 project to Android project with the reference with this link. And I conclude some problems I met in my Blogger. I also found an official tutorial

To conclude:

  1. Setup Java Build Path
  2. Setup Builder Settings, I didn't use cygwin but using ndk_build
  3. Setup NDK_MODULE_PATH
  4. Copy the Resources
  5. Modify Android.mk

Upvotes: 0

TankorSmash
TankorSmash

Reputation: 12747

For cocos2dx v3, you need to run cocos compile -p android from within the project's directory. You need to make sure to have your JAVA_HOME path set correctly in your environment variables.

I can't say for sure that it mattered, but I had run proj.android/build_native.py as admin through cmd.exe before hand.

Upvotes: 0

aajiwani
aajiwani

Reputation: 121

You need the classes and resources folder in the project created. Once done, you need to add all the CPP files and the includes folder in Android.mk file and build it using a script available build_native.sh

Upvotes: 1

Related Questions