Cocos2D JS and Android Studio

Cocos2D JS and Android Studio
0.0 0

#1

Cocos2D JS v3.7 added support for Android Studio. But as far as I know there is no official guide for it. I know about the “cocos compile” command but I am not sure about how it works. Therefore I am asking for a step by step guide about how to setup a Cocos2D JS project in android studio (without using the “cocos compile” command).

Any help will be greatly appreciated.


#2

@SonarSystems do you have any video about setting up the project on android studio?


#3

@pandamicro @zhangxm


#4

@mr746866
Now you can only use Android Studio to compile java codes and generates apk, you can not use it to compile c++ codes.

What you should do is:

  • use cocos to create a new js project
  • use Android Studio to open the project
  • use cocos compile to compile c++ codes
  • use Android Studio to generate apk file

#5

We do indeed


#6

do you have any video about setting up the project on android studio?


#7

Does that video not cover what you need?


#8

I have this error when running the above command :

cocos compile -p android --android-studio

Building mode: debug
Using Android Studio project : E:\Workspace\Cocos2d-js\ColorSmash\frameworks\runtime-src\proj.android-studio
running: ‘“E:\sdk\adt-bundle-windows-x86_64-20130729\sdk\tools\android” update project -t android-13 -p E:\Workspace\Cocos2d-js\ColorSmash\frameworks\runtime-src\proj.android-studio\app’

Updated project.properties
Updated local.properties
Updated file E:\Workspace\Cocos2d-js\ColorSmash\frameworks\runtime-src\proj.android-studio\app\proguard-project.txt
Building native…
NDK build mode: debug
running: ‘“E:\sdk\android-ndk-r11-windows-x86_64\android-ndk-r11\ndk-build” -C E:\Workspace\Cocos2d-js\ColorSmash\frameworks\runtime-src\proj.android-studio\app -j4 NDK_MODULE_PATH=E:\Workspace\Cocos2d-js\ColorSmash\frameworks\cocos2d-x;E:\Workspace\Cocos2d-js\ColorSmash\frameworks\cocos2d-x\cocos;E:\Workspace\Cocos2d-js\ColorSmash\frameworks\cocos2d-x\external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1’

make: Entering directory E:/Workspace/Cocos2d-js/ColorSmash/frameworks/runtime-src/proj.android-studio/app' [armeabi] Gdbserver : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver [armeabi] Gdbsetup : libs/armeabi/gdb.setup [armeabi] Compile++ thumb: cocos2djs_shared <= main.cpp [armeabi] Compile++ thumb: cocos2djs_shared <= AppDelegate.cpp [armeabi] Compile++ arm : cocos2d_js_static <= jsb_cocos2dx_3d_auto.cpp [armeabi] Compile++ arm : cocos2d_js_static <= jsb_cocos2dx_extension_auto.cpp [armeabi] Compile++ arm : cocos2d_js_static <= jsb_cocos2dx_3d_extension_auto.cpp In file included from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../extensions/assets-manager/AssetsManagerEx.h:38:0, from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../extensions/cocos-ext.h:16, from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../auto/jsb_cocos2dx_extension_auto.cpp:3: E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../extensions/assets-manager/Manifest.h:37:35: fatal error: json/document-wrapper.h: No such file or directory #include "json/document-wrapper.h" ^ compilation terminated. make: *** [obj/local/armeabi/objs-debug/cocos2d_js_static/__/auto/jsb_cocos2dx_extension_auto.o] Error 1 make: *** Waiting for unfinished jobs.... In file included from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../extensions/assets-manager/AssetsManagerEx.h:38:0, from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../extensions/cocos-ext.h:16, from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../auto/jsb_cocos2dx_3d_extension_auto.cpp:3: E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../extensions/assets-manager/Manifest.h:37:35: fatal error: json/document-wrapper.h: No such file or directory #include "json/document-wrapper.h" ^ compilation terminated. make: *** [obj/local/armeabi/objs-debug/cocos2d_js_static/__/auto/jsb_cocos2dx_3d_extension_auto.o] Error 1 In file included from E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../auto/jsb_cocos2dx_3d_auto.cpp:4:0: E:/Workspace/Cocos2d-js/ColorSmash/frameworks/cocos2d-x/cocos/3d/../3d/CCBundle3D.h:31:35: fatal error: json/document-wrapper.h: No such file or directory #include "json/document-wrapper.h" ^ compilation terminated. make: *** [obj/local/armeabi/objs-debug/cocos2d_js_static/__/auto/jsb_cocos2dx_3d_auto.o] Error 1 make: Leaving directoryE:/Workspace/Cocos2d-js/ColorSmash/frameworks/runtime-src/proj.android-studio/app’
Error running command, return code: 2.
srikanth@YASASWI E:\Workspace\Cocos2d-js\ColorSmash


#9

What version of Cocos2d-x are you using?


#10

The latest version : Cocos2d-JS v3.14


#11

I experience the same issue!
Updated cocos2d-x from 3.13.1 to 3.14 and it doesn’t compile for android =(


#12

Hi @ysrikanth2011 , were you able to create apk from a cocos2d-x javascript project?


#13

btw, my issue was solved. Just did some updating from github