Reputation:
I have just started learning cocos2d-x-3.11.1 in android studio (trying to compile with native C++ language) and I am getting this following error and a message on my phone "Unfortunately libcocos2dx has stopped"
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.granjur.org-1/base.apk"],nativeLibraryDirectories=[/data/app/com.granjur.org-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libMyGame.so"
I have configured NDK
, SDK
and the ANT
folders correctly from command line. I've been stuck with this from last two days!
AndroidManifest.xml
<uses-feature android:glEsVersion="0x00020000" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher">
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="MyGame" />
<activity
android:name="org.cocos2dx.cpp.AppActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
logcat:
06-20 10:58:32.922 15649-15649/com.granjur.org E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.granjur.org, PID: 15649
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.granjur.org-1/base.apk"],nativeLibraryDirectories=[/data/app/com.granjur.org-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libMyGame.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:246)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:260)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-20 10:59:39.226 15649-15649/com.granjur.org I/Process: Sending signal. PID: 15649 SIG: 9
Any help would be highly appreciated! Thank you!
Upvotes: 3
Views: 4133
Reputation: 11
Finally I have a genuine solution to the above problem for users working on android studio project of cocos2dx 3.8.1 above.
Just add this line in Application.mk :)
APP_ABI := armeabi-v7a
Sample Application.mk file :
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
APP_ABI := armeabi-v7a
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
APP_ABI := armeabi-v7a
endif
The main problem was the device architecture compatibility with your application. We need to give exclusive support to devices with ARM architecture armeabi-v7a when running proj.android-studio.
Hope this will help many other like me.
Upvotes: 1
Reputation: 21
Run this command at the game directory to compile the source once:
cocos compile -p android --android-studio
Upvotes: 2