Cocos2dx 3.1.1 porting Android apk (in mac environment for lua project cross-compilation)

Source: Internet
Author: User

Cocos2dx 3.1.1 porting Android apk (in mac environment for lua project cross-compilation)
Cocos2dx 3.1.1 This article is based on ant, sdk, ndk, adt and other software and environment in the mac environment of Android cross-compiling for lua project.
1 \ create a project and run the following command on the mac terminal: cocos new tegame-p com. test. app-l lua (a custom path can be added later)

After the environment is set up, you can directly enter the preceding statements to create a project.

The new lua project is the cocos project that we use to compile to Android. the new document, the engine itself has written the mk file, which does not need to be modified or edited. It is relatively simple. applicable to beginners. use xcode to compile and run the program. After seeing that the farm screen is normal, execute the next step.
2 \ compile the so file first use the terminal cd to enter the newly created project directory, and then run the command cocos compile-p android
3 \ package apk with eclipse (1) import the project to eclipse and select File> New> Project. For example, click Android> Android project from Existing Code and select the Project path, then press confirm next.
(2) after the project is imported to eclipse, the error Cocos2dxActivity cannot be resolved to a type is returned. the import org. cocos2dx. lib cannot be resolved indicates that the following file cannot be found: import org. cocos2dx. lib. cocos2dxActivity; solution: just copy the lib folder under the cocos/platform/android/java/src/org/cocos2dx folder in the root directory of the cocos2d-x engine to the project's proj. android/src/org/cocos2dx folder.

Right-click the project and select Refresh.

(3) New error:

The method getAudioSessionId () of type Cocos2dxVideoView must override or implement a super type method

Error content:

@ Override

Public int getAudioSessionId (){

// TODO Auto-generated method stub

Return mMediaPlayer. getAudioSessionId ();

}

Solution:

Delete the @ Override line and re-compile it.


_________

The apk generated after compilation is run on a real machine. It is a black screen and has nothing to do with it.

This is because our resources have not been placed in the assets path, so the black screen is invisible.

The last step is to put the resources in the assets folder of Android.


(4) copy the res and src folders under the project root directory to the folder generated when the so file is generated. The path is/frameworks/runtime-src/proj under the project. android/assets

At the same time, all the lua files in the path/frameworks/cocos2d-x/cocos/scripting/lua-bindings/script under the project root directory should also be copied to the assets Directory

Right-click the project and select Refresh.

Right-click the project name and choose run as> Android Application]

The generated apk can be used normally!


Reference http://blog.csdn.net/wtuetnsrmh/article/details/28723895http://blog.csdn.net/nanlus/article/details/36380855 http://blog.csdn.net/dyllove98/article/details/8829919

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.