Steps for cocos2dx to generate an Android APK File

Source: Internet
Author: User

Steps for cocos2dx to generate an Android APK File

The following figure shows the result of my operation steps (real machine display)

First, you need to prepare the software (with the java environment configured on your own). Below is a method,

1. ADT download

2. To download the NDK, You need to configure the environment variable NDK_ROOT value as the address where the NDK is located.

3. MinGW (used to run the sh script)


When you fully configure the java environment and the NDK environment. We will not discuss the environment here, or we will talk a lot about it.

After creating a cocos2dx project, open MinGW to enter the project's proj. Android folder.

Enter./build_native.sh to run the program. (Note: do not modify the Project C ++ source code first, because the project will be modified a lot and will be explained in detail later)

The interface is shown below (the following interface prompts less information because this project has performed this step)


Open the ADT and import the project.






Click next and next.

After loading, check hellocpp. java to find the error (of course, I have modified the following and no error is displayed)

Solution: Copy (the address is subject to your) E: \ cocos2d-x-2.2.1 \ cocos2dx \ platform \ android \ java \ src under the org folder

E: \ cocos2d-x-2.2.1 \ projects \ 2048_BOJIE \ proj. android \ src

Then refresh the adt



If no error is found, a package error may occur in some projects.

The first line of the image below. Follow the adt prompt to change the package name.


Then, at this time, adt will help you generate an APK under the \ bin \ res file, but this APK cannot be started properly after installation.

Why ???

Because we modified the package just now and it was not modified in the xml file. Right-click to open AndroidMainfeast. xml

Change the package name to the package name you just modified.


In this way, refresh and run on the virtual machine.


Take the time tonight to write the following content.

How can I modify some of my own classes in the class file? As shown in, add the NewSPrite class

This class is shared across platforms.

Android. mk is enough. Right-click and choose LOCAL_SRC_FILES: = hellocpp/main. cpp \
.../../Classes/AppDelegate. cpp \
.. /.. /Classes/HelloWorldScene. modify cpp to FILE_LIST: = hellocpp/main. cpp FILE_LIST + = $ (wildcard $ (LOCAL_PATH )/.. /.. /Classes /*. cpp)
LOCAL_SRC_FILES :=$ (FILE_LIST: $ (LOCAL_PATH)/% = %) will help you load all the class files
Then run MinGW to run bulid_native.sh. 

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.