COCOS2DX 3.1.1 Lua Project Android cross-compiling MAC environmentThis article is based on Ant,sdk,ndk,adt and other software and environment has been set up in advance
1\ New project under the terminal of Mac Enter command: Cocos new Tegame-p Com.test.app-l Lua (can add custom path later)
After the environment is set up, you can enter the above statement to create a new project.
This new LUA project is the Cocos project we used to compile to Android. The new document, the engine itself has written the Mk file, does not need to be modified and edited, relatively simple. Suitable for beginners to learn. Run with Xcode first, and see the farm screen to perform the next step.
2\ compiling so files use the terminal CD to enter the newly created project directory before running the command Cocos compile-p Android
3\ Use Eclipse pack apk (1) To import the project into Eclipse Select File->new->project, for example, click Android->android Project from Existing Code, Select the project path and press confirm next.
(2) An error occurred after importing the project into Eclipse Cocos2dxactivity cannot is resolved to a type. The import Org.cocos2dx.lib cannot be resolved this issue, is prompted to find the following documents: Import Org.cocos2dx.lib.Cocos2dxActivity; Solution: Simply copy the Lib folder under the Cocos/platform/android/java/src/org/cocos2dx folder of the root directory of the Cocos2d-x engine to the project's proj.android/src/org/ The Cocos2dx folder.
Then right-click on the project to select Refresh
(3) New error:
The method Getaudiosessionid () of type Cocos2dxvideoview must override or implement a Super type method
What the error points to:
@Override
public int Getaudiosessionid () {
TODO auto-generated Method Stub
return Mmediaplayer.getaudiosessionid ();
}
Workaround:
Delete @override this line and recompile again
_________
After compiling the generated apk, the real machine runs, is black screen, nothing.
This is because our resources have not been placed in the path of assets, so the black screen is invisible.
So take the last step and put the resources in the Assets folder on Android.
(4) Copy the res and src two folders under the project root directory to the folder generated when the so file is generated, the path is/frameworks/runtime-src/proj.android/assets under the project
At the same time, all LUA files in the path/frameworks/cocos2d-x/cocos/scripting/lua-bindings/script below the project root directory are also copied to the assets directory.
Then right-click on the project to select Refresh
Right-click Project Name, "Run as"--"Android application"
The generated APK will work properly!
Reference http://blog.csdn.net/wtuetnsrmh/article/details/28723895http://blog.csdn.net/nanlus/article/details/ 36380855 http://blog.csdn.net/dyllove98/article/details/8829919
Cocos2dx 3.1.1 Porting Android APK (LUA project cross-compiling MAC environment)