How to deploy the Cocos2dx-lua project with Androidstudio

Source: Internet
Author: User

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:

  
 
  1. sourceSets.main {
  2. jni.srcDirs = []
  3. jniLibs.srcDir ‘path/to/libs‘
  4. assets.srcDir ‘path/to/assets‘
  5. }

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

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.