我刚开始在android studio中学习cocos2d-x-3.11.1(尝试使用原生C ++语言编译),我收到以下错误并在手机上显示一条消息"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"
我已从命令行正确配置了NDK
,SDK
和ANT
个文件夹。过去两天我一直坚持这个!
的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
任何帮助都将受到高度赞赏! 谢谢!
答案 0 :(得分:2)
在游戏目录中运行此命令以编译源一次:
cocos compile -p android --android-studio
答案 1 :(得分:1)
最后,对于使用上述cocos2dx 3.8.1的android studio项目的用户,我有一个真正的解决方案。
只需在Application.mk :)中添加此行
APP_ABI := armeabi-v7a
示例Application.mk文件:
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
主要问题是设备架构与您的应用程序的兼容性。运行proj.android-studio时,我们需要为ARM架构armeabi-v7a的设备提供独家支持。
希望这会有很多像我一样的人。