How to import android project to eclipse so we can call java from JS?

Hey ! I want to import a Cocos2d-js project to eclipse so I can code java call from JS and test with android ?

After a struggle of a couple of hours,
I am able to import the project in Eclipse.

You need to manually compile the project from command line:-

$ cocos compile -p android

then manually copy the files to assests folder of your proj.android/

cd to your proj.android and then
$ cp …/…/…/project.json assets/
$ cp -a …/…/…/main.js .
$ cp -a …/…/…/res/ assets/
$ cp -a …/…/…/src/ assets/
$ cp -a …/…/js-bindings/bindings/script/ assets/script/

also, you need to import the cocos lib for android from:-
cocos2d-js-v3.0-rc2/frameworks/js-bindings/cocos2d-x/cocos/platform/android/java

and fix the properties of eclipse project to point to this lib.

Hope this helps you.

thanks

1 Like