Hell everyone. Yesterday I downloaded the 3.7 version and when I create a new project with cocos command line tool, I realized there is a new proj folder named android-studio with gradle and everything.
Bu I can’t find any tutorial about it, well normally with the proj.android, we use cocos command line tool to build and deploy for android, but it seems there is no script like build_native.py in proj.android-studio, and when I try to make and run it with Android Studio, it gives me some missing library errors.
Here what is like;
07-22 11:24:35.860 22141-22141/com.oms.impact E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.example.hello-2.apk,libraryPath=/data/app-lib/com.example.hello-2]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:355)
at java.lang.System.loadLibrary(System.java:525)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:207)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:222)
at android.app.Activity.performCreate(Activity.java:5372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
at android.app.ActivityThread.access$700(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)
I think it’s related with the missing .so files. How can I natively build libraries for proj.android-studio and run my application with it?
It would be great to explain the basic principles how AndroidStudio co-exists with cocos console and with android make files.
What is actually used by the compilation. Gradle configs or the Android make files?
What is the configuration life-cycle? Where do I make configuration changes: android makefiles, gradle configs, android studio settings? When/what do I synchronize?
What is the proper way of importing dependent modules e.g. Facebook plugins?
a. When I’ve imported the plugin then AndroidStudio copied all the
Java files to proj.android-studio folder. I’ve ended up with extra folders libPluginFacebook and libPluginProtocol. This might be desirable
but not always. Sometimes you want to shared the big dependencies.
b. where do I set the classpath? When I compile the project the I receive compilation errors shown bellow. You can see that compiling libPluginProtocol is completed and now I’m receiving the errors from libPluginFacebook:compileReleaseJava where most of them relate to dependencies to libPluginProtocol. Where do I set it? Is not sufficient to say that libPluginFacebook depends on libPluginProtocol?
Mentioned compilation errors:
Skipping task ':libPluginProtocol:assembleDebug' as it has no actions.
:libPluginProtocol:assembleDebug UP-TO-DATE
:libPluginProtocol:assembleDebug (Thread[Task worker Thread 3,5,main]) completed. Took 0.001 secs.
/pp/src/tests/testAS/TestAS/frameworks/runtime-src/proj.android-studio/libPluginFacebook/src/main/java/org/cocos2dx/plugin/FacebookWrapper.java:7: error: cannot find symbol
import com.facebook.AppEventsLogger;
^
symbol: class AppEventsLogger
location: package com.facebook
/pp/src/tests/testAS/TestAS/frameworks/runtime-src/proj.android-studio/libPluginFacebook/src/main/java/org/cocos2dx/plugin/FacebookWrapper.java:8: error: cannot find symbol
import com.facebook.UiLifecycleHelper;
^
symbol: class UiLifecycleHelper
location: package com.facebook
/pp/src/tests/testAS/TestAS/frameworks/runtime-src/proj.android-studio/libPluginFacebook/src/main/java/org/cocos2dx/plugin/FacebookWrapper.java:9: error: package com.facebook.widget does not exist
import com.facebook.widget.FacebookDialog;
Thanks a lot for giving some light into all this!
–Josef
thanks, just wanted to blame on you that you doing this video to long as this is is most useful feature of 3.7 cocos.
Ok, watched video - why you not adding gradle command which will execute “cocos compile …” in command line automatically when you press run in Android Studio, so you nod need to run separately this command in terminal.
The command line build works for a new project. But doesn’t seem to work for my existing project. Where should the rules for making the target be added?
I copied all the files listed in Android.mk in proj.android to Android.mk in proj.android-studio.
Otherwise the files look similar. Any changes to be made ?
I can compile for android fine. Just not android studio
EDIT: The problem was that the paths I specified in Android.mk for proj.android-studio was incorrect. As it is one more folder down, I should have put …/…/…/ instead of …/…/ . Its compiling now. But its taking forever for android studio to open.
I’ve just downloaded v3.7, yesterday. However when I tried to create new project with command line tool or even with Cocos app, I don’t see any project names proj.android-studio