December 28, 2015

Setup Cocos2d-x 3.9 Part 6: Build Cocos2d-x project with Cocos Console.

This is part 6 of "Setup Cocos2d-x 3.9" series. Refer to the previous posts to make sure you are all set to working on this part:

Part 1

Just remind in the part 5, I mentioned about Cocos2d-x does still not support to build games directly in Android Studio and need to build with Cocos Console. To do that, please check out these steps:

Step 1: In the "Android Studio Setup Wizard", select option "Open an existing Android Studio project"

Step 2: Browse to "C:\Games\YumikiTutorial\proj.android-studio" and click "OK".

Step 3: Then click on "Project" tab on the left and select "Android" on dropdownlist. Make sure that it display 3 projects in the Android Panel:
  • YumikiTutorial
  • libcocos2dx
  • Gradle Scripts

Step 4: Open "Command Prompt" and locate to path "C:\Games\YumikiTutorial\proj.android-studio" by typing:
cd C:\Games\YumikiTutorial\proj.android-studio

Step 5: Type cocos command to build the android studio project.
cocos compile -p android --android-studio

Note: During compiling code, it will download some libraries from the Internet. So it may be failed to download some time. No worry, just run the cocos command again and it will download again the missing libraries.

And you may get the Java errors while compiling, in this case, your OS may miss the JAVA_HOME in Environment Variables. Just add that value to Local Variable and the value is the path of Java (Example: C:\Program Files\Java\jdk1.8.0_65) .

Once it is finished, the result in Command Prompt will display like this:

Finallty, the final step is to run the project in Android Studio to test the result or you can locate to "C:\Games\YumikiTutorial\proj.android-studio\app\build\outputs\apk" to install the APK file in your real devices to test.

If you have any questions or concerns, please post your comments here, I will take a look and response ASAP.

Yumiki.

No comments :

Post a Comment