if the command line is daunting, we can cross-compile with the Eclipse tool with the ADT plugin installed.
Using Eclipse for cross-compiling, you first need to import the project to be compiled into Eclipse's workspace, Workspace is a collection of multiple projects. The specific step is to start Eclipse, select Menu File→new→project, pop Up the new Project dialog box shown in 21-18, and select Android→android project from Existing Code.
New Project dialog box in the New Project dialog box, click the Next button, pop up as shown in the Import Project dialog box, click the Browse button, pop up the Selection Directory dialog box shown below, note that the selection directory is: "< game project Path >\proj.android", In this directory there are files required to create an Eclipse Android project.
Import Project Dialog box
Select Directory dialog box after selecting the directory, click the OK button to close the dialog box, back to the Import Project dialog, as shown in the root directory already has the content. If there is no error stating that the selection project was successful. Note that we do not select the Copy projects into workspace option. Select Finish to click on the Finish button.
Select project Success however, after clicking Finish, Eclipse Imports and compiles the project, and when the compilation is complete, it will find a lot of errors, as shown in. It is not difficult to find that the cause of these errors is that cocos2d-x is not found on the Android platform Java class, these classes are located in the:< Game project path >\cocos2d\cocos\2d\platform\android\java directory , we either copy the Java file under this directory to the SRC directory of the current project or import the Cocos2d-x Android Java Library project.
Compile error import cocos2d-x Android Java Class Library project is similar to the previous Import game project, the path chosen is:< game engineering path >\cocos2d\cocos\2d\platform\android\java. As shown in the successful import of the LIBCOCOS2DX project.
Successful import LIBCOCOS2DX Project tips Many readers will ask, just import LIBCOCOS2DX project, game Engineering Mygame can find the Java class files you need! This is because there is a project.properties file in the Mygame project, android.library.reference.1= in this file. The/cocos2d/cocos/2d/platform/android/java Setup item describes the dependencies between the two projects.
The successful compilation of the two projects in eclipse does not mean that the game project has been cross-compiled, and we need to perform the < game engineering path >\proj.android\build_native.py to cross-compile to generate the. so file. Execution build_native.py can be executed through the DOS terminal into the directory build_native.py, which can be executed by double-clicking build_native.py in Eclipse, as shown in the execution process.
Perform build_native.py cross-compilation if Build_ is executed native.py Cross Compilation succeeds, we also need to select the Mygame project in Eclipse, press the F5 key to refresh the project, otherwise, the libcocos2dcpp.so file as shown in the project is not visible.
libcocos2dcpp.so file
Cross-compile successfully can be packaged and run, choose Mygame Project, right-click menu Run as→android Application, and then select the emulator or Android device you want to package and run.
For more information, please pay attention to the first Cocos2d-x 3.2 Edition book "Cocos2d-x: C + + volume" book Exchange discussionwebsite: http://www.c ocoagame.net
For more exciting video courses, please follow Cocos class: http://v.51work6.com
Welcome to join Cocos2d-x Technical Discussion group: 257760386 Welcome to Luxgen iOS Classroom public platform
Cocos porting to android-using Eclipse cross-compilation packaging