The problems of cocos2d-x-3.7 used in android studio

I want to use cocos2d-x-3.7 in android studio.
And I found some informations like “cocos2d-x-3.7/tools/cocos2d-console/bin/cocos compile -p android --android-studio”,and import the proj.android-studio to android studio. The proj.android-studio is contained in the cocos2d-x-3.7.

But I got some problems. Show below, and anyone can help me to resolve these problems.

F:\javac\cocos2d-x-3.7\cocos2d-x-3.7>setup.py

Setting up cocos2d-x…
->Check environment variable COCOS_CONSOLE_ROOT
->Search for environment variable COCOS_CONSOLE_ROOT…
->COCOS_CONSOLE_ROOT is found : F:\javac\cocos2d-x-3\cocos2d-x-3\tools\cocos
2d-console\bin

->Remove directory "F:\javac\cocos2d-x-3\cocos2d-x-3\tools\cocos2d-console\bin
" from PATH!

->Add directory “F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tools\cocos2d-console\bi
n” into PATH succeed!

->Force update environment variable COCOS_CONSOLE_ROOT
->Succeed : COCOS_CONSOLE_ROOT=F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tools\co
cos2d-console\bin
->Check environment variable COCOS_TEMPLATES_ROOT
->Search for environment variable COCOS_TEMPLATES_ROOT…
->COCOS_TEMPLATES_ROOT is found : F:\javac\cocos2d-x-3\cocos2d-x-3\templates

->Remove directory “F:\javac\cocos2d-x-3\cocos2d-x-3\templates” from PATH!

->Add directory “F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\templates” into PATH suc
ceed!

->Force update environment variable COCOS_TEMPLATES_ROOT
->Succeed : COCOS_TEMPLATES_ROOT=F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\templa
tes
->Configuration for Android platform only, you can also skip and manually edit y
our environment variables

->Check environment variable NDK_ROOT
->Search for environment variable NDK_ROOT…
->NDK_ROOT is found : F:\javac\android-ndk-r10e

->Check environment variable ANDROID_SDK_ROOT
->Search for environment variable ANDROID_SDK_ROOT…
->ANDROID_SDK_ROOT is found : F:\javac\adt-bundle-windows\sdk

->Check environment variable ANT_ROOT
->Search for environment variable ANT_ROOT…
->ANT_ROOT is found : F:\javac\adt-bundle-windows\apache-ant-1.9.6-bin\apach
e-ant-1.9.6\bin

Please restart the terminal or restart computer to make added system variables t
ake effect

F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests>cd project

F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project>cd proj.android-stud
io

F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project\proj.android-studio>
dir
驱动器 F 中的卷没有标签。
卷的序列号是 8456-20BC

F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project\proj.android-studio
的目录

2015/09/29 20:42

.
2015/09/29 20:42

2015/05/27 17:02 91 .gitignore
2015/09/29 19:53
app
2015/06/16 23:53 769 build-cfg.json
2015/05/27 17:02 436 build.gradle
2015/07/21 10:24
gradle
2015/05/27 17:02 855 gradle.properties
2015/06/02 10:08 5,080 gradlew
2015/05/27 17:02 2,314 gradlew.bat
2015/09/29 20:42 428 local.properties
2015/06/02 10:08 213 settings.gradle
8 个文件 10,186 字节
4 个目录 57,317,797,888 可用字节
F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project\proj.android-studio>
F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tools\cocos2d-console\bin\cocos compile -p
android --android-studio
执行命令:compile
编译模式:debug
使用 Android Studio 工程:F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\pr
oject/proj.android-studio
未指定 Android 目标平台版本,自动查找一个可用版本…
正在执行:’“F:\javac\adt-bundle-windows\sdk\tools\android” update project -t and
roid-10 -p F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project/proj.andr
oid-studio\app’

‘xcopy’ 不是内部或外部命令,也不是可运行的程序
或批处理文件。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
系统找不到指定的路径。
Updated project.properties
Updated local.properties
Updated file F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project\proj.an
droid-studio\app\proguard-project.txt
正在执行 ndk-build…
NDK 编译模式:debug
从 F:\javac\android-ndk-r10e\RELEASE.TXT 文件获取 NDK 版本失败。
NDK_TOOLCHAIN_VERSION: 4.8
正在执行:’“F:\javac\android-ndk-r10e\ndk-build” -C F:\javac\cocos2d-x-3.7\cocos
2d-x-3.7\tests\js-tests\project/proj.android-studio\app -j4 NDK_MODULE_PATH=F:\j
avac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project/proj.android-studio…/.
./…/…;F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project/proj.android
-studio…/…/…/…/cocos;F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\pr
oject/proj.android-studio…/…/…/…/external NDK_TOOLCHAIN_VERSION=4.8 NDK_DEB
UG=1’

系统找不到指定的路径。
执行命令出错,返回值:1。
F:\javac\cocos2d-x-3.7\cocos2d-x-3.7\tests\js-tests\project\proj.android-studio>

I believe that version 3.8.1 supports Android Studio.

Could you share how to use 3.8.1 in android studio?

I believe cocos new creates an Android Studio project.

Yes.
I have move the cocos2d-x.3.8 project to Android Studio.And the project can run.
And something I do not know. How I add some code in the project?

The code contained in the AppActivity file:
package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;

public class AppActivity extends Cocos2dxActivity {

}

import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
The “unused import statement” occured.
Could you help me?

I want to add code in my android studio project with cocos2dx-3.8.1.
The code is “CCDirector mDirector;”. I want to add CCDirector object.
But CCDirector can not be used.
Could you help me.

In v3.x it is just Director. CCDirector was v2.6

How do I use Director? And could you give me the code sample used Director?
When I enter the “Director” in the file AppActivity.java, it show the red of “Director” . The red means that no use of “Derector”

Sorry, maybe I misunderstand, What are you doing in AppActivity.java with Director?

I want to code with cocos2d-x-3.7 lib.
I have build the cocos2d-x-3.7 success.
And I have imported the cocos2d-x-3.7 to android studio.
But I do not know how to use Director.
It failed to create the object used with class Director.

The actual code of the game should be in Classes folder, not in AppActivity.java.

Could you tell me more detail.
The “libcocos2dx” has been imported to the project.
And the “org.cocos2dx.lib” contain many folders.
For example,
Cocos2dxAccelerometer
Cocos2dxActivity.java
Cocos2dxBitmap
Cocos2dxEditBox

Could you tell me more detail.
The “libcocos2dx” has been imported to the project.
And the “org.cocos2dx.lib” contain many folders.
For example,
Cocos2dxAccelerometer
Cocos2dxActivity.java
Cocos2dxBitmap
Cocos2dxEditBox

But no Cocos2dxDirector folder.

So you should create new .cpp and .h files inside Classes folder and there should be the actual code of the game, not in AppActivity.java.

This link should help you: http://www.sonarlearning.co.uk/coursepage.php?topic=game&course=cocos2d-x-v3