Background description
Recently in the development of learning Cosox2dx-lua, the Cocos Code IDE was used as a development tool. Because of the project requirements, I need to import another library I have developed myself. Because the library contains interface and resource files, I package it as an arr package. This time found tragedy, Eclipse does not seem to support the import ARR package, COCOS2DX automatic tools do not support Androidstudio, after a long and painful toss, I found a compromise approach, although it will be a little trouble, but at least can use ...
Related tools
Cocos Code IDE build:v1.1.0
Androidstudio 1.0.2
COCOS2DX 3.3.1
Lua 5.1
Operation Step 1. New Cocos-lua Project
Create a new Cocos Lua project using the Cocos Code IDE
Check添加C++代码
At this point, go to the Cocos Code IDE workspace and find the newly createdCocosLuaGame1Project, enterframeworks/runtime-src/Directory, findproj.android, this is the Android project that will be used later
2. Import Androidstudio
Open Androidstudio, selectFile->Import Project, in the file browser, locate theproj.androidProject
ClickOK, the following dialog box appears, select a path and selectnext, and then selectfinish
Androidstudio automatically creates the appropriate project and copies the required libraries, such as libcocos2dx .
3. Setting Up Mappings
You cannot compile the project directly with Androidstuido at this time. Go back to the Cocos Code IDE and selectpackage to APKAfter selecting the appropriate Android SDK version, select生成。 At this point the Cocos Code IDE automatically compiles the relevant C + + and LUA code. Open the previousproj.androidWorks, and you can see that there are alreadylibsAndassetsfolder, remember the absolute path to both folders.
Back to Androidstudio, open belongs to cocosluagame1 module build.gradle file, android module, add the following code:
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir ‘path/to/libs‘
assets.srcDir ‘path/to/assets‘
}
Two of these paths are the absolute paths of the two folders that you just need to remember.
Select Run to see the default items for COCOS2DX in your phone or simulator.
At this point, you can do what you want to do in androidstudio, such as adding third-party jars, arr packages, writing Android native code, and so on. If the Cocos-lua part of the code needs to change, just modify and recompile in the Cocos Code IDE (no way to compile directly with Androidstudio ...). Keng...... )
How to deploy the Cocos2dx-lua project with Androidstudio