运行cocoa2dx项目时出错

时间:2016-09-16 12:34:25

标签: android cocoa android-studio cocos2d-x cocos2d-android

清单

<application android:label="@string/app_name" 
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 ............../> </intent-filter> </activity> 
</application>

错误:

com.xxx.xxxxxx E/AndroidRuntime: FATAL EXCEPTION: main Process: com.xxx.xxxxxxx, PID: 15913 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.xxx.xxxxx-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] 
>couldn't find "libMyGame.so"                                      at java.lang.Runtime.loadLibrary(Runtime.java:366)
                                                                   at java.lang.System.loadLibrary(System.java:989)
                                                                   at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
                                                                   at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
                                                                   at android.app.Activity.performCreate(Activity.java:5966)
                                                                   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2408)
                                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
                                                                   at android.app.ActivityThread.access$800(ActivityThread.java:162)
                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1412)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                   at android.os.Looper.loop(Looper.java:189)
                                                                   at android.app.ActivityThread.main(ActivityThread.java:5532)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at java.lang.reflect.Method.invoke(Method.java:372)
                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)

它将我重定向到文件

  

代码行中的Cocos2dxActivity.java:248 System.loadLibrary(libName);

我遇到了这个错误。帮助我。

我正在使用cocos2d-x-3.13

Android NDK, Revision 12 
Latest SDK
Android-studio 2.1.3
python 2.7.12
apache-ant 1.9.7
JDK 1.8

提前致谢。

1 个答案:

答案 0 :(得分:2)

couldn't find "libMyGame.so"

发生此错误的原因是您没有针对要测试的体系结构进行编译。

在Application.mk文件中更改为:

APP_ABI := armeabi armeabi-v7a x86

然后重新编译并测试。