Migrate Cocos to Android-use Eclipse for cross-compilation and packaging, cocosandroid-

Source: Internet
Author: User

Migrate Cocos to Android-use Eclipse for cross-compilation and packaging, cocosandroid-
If the command line is daunting, we can use the Eclipse tool installed with the ADT plug-in to achieve cross-compilation.
To use Eclipse for cross-compilation, first import the project to be compiled to the Eclipse Workspace, which is a collection of multiple projects. After Eclipse is started, select File> New> Project. The Create Project dialog box from is displayed. Select Android> Android Project from Existing Code.

In the Create Project dialog box, click "Next" in the new project dialog box. The import project dialog box as shown in is displayed. Click "Browse". The "Select Directory" dialog box is displayed. Note that the "Select Directory" dialog box is displayed: "<game engineering path> \ proj. android ", which contains the files required to create an Eclipse Android project.



Import project dialog box
Select the Directory dialog box and click OK to close the dialog box. Return to the import project dialog box, as shown in. The Root Directory already contains content. If no error is reported, the project is selected successfully. Do not select the Copy projects into workspace option. Click Finish.





After the project is selected successfully, click Finish to import and compile the project in Eclipse. Many errors will be found after compilation, as shown in. After research it is not difficult to find the cause of these errors is that the Cocos2d-x In the Android platform Java class, these classes are located in: <game project path> \ cocos2d \ cocos \ 2d \ platform \ android \ java directory, we either copy the Java files under this directory to the src directory of the current project, either import the Cocos2d-x Android Java class library project.

Compilation error import Cocos2d-x Android Java class library project operation steps are similar to the previous import game project, the path is selected: <game engineering path> \ cocos2d \ cocos \ 2d \ platform \ android \ java. As shown in, the libcocos2dx project is successfully imported.

Successfully importing the libcocos2dx project prompts many readers to ask, just import the libcocos2dx project, can the game project MyGame find the required Java class file! This is because there is a project in the MyGame project. properties file. In this file, android. library. reference.1 = .. the/cocos2d/cocos/2d/platform/android/java setting describes the dependencies between two projects.
The two projects are successfully compiled in Eclipse, which does not mean that the game project has been cross-compiled. We need to execute <game project path> \ proj. android \ build_native.py to generate the. so file. Run build_native.py to enter the directory build_native.py through the DOS terminal. You can double-click build_native.py in Eclipse to execute it. The execution process is shown in.

Run build_native.py cross-compilation. If the build_native.py cross-compilation is successful, we also need to select the MyGame project in Eclipse and press F5 to refresh the project. Otherwise, the libcocos2dcpp. so file shown in the project is not displayed.

Libcocos2dcpp. so file

After the cross-compilation is successful, you can package and Run the program. Right-click the MyGame project, choose Run as> Android Application, and select the simulator or Android device to package and Run.



More content please pay attention to the first domestic Cocos2d-x 3.2 version of the book "Cocos2d-x practice: C ++ volume" book exchange discussion site: http://www.cOcoagame.net
For more exciting video courses, please follow the Cocos course in Zhijie class: http: // v.51wOrk6.com
Welcome to the Cocos2d-x Technology Discussion Group: 257760386 welcome to the knowledge of the iOS classroom public platform

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.