Help us understand the problem. What is going on with this article?

[cocos2d-x]アプリ起動時に落ちる(Android)

More than 3 years have passed since last update.

Env

  • OSX 10.11.3
  • Android 4.4.4(実機)
  • cocos2d-x 3.13
  • Android SDK tools 25.1.7
  • Android NDK r10d
  • apache ANT 1.9.7
  • JDK 1.8.0_102

Ref

http://stackoverflow.com/questions/28740315/android-ndk-getting-java-lang-unsatisfiedlinkerror-dlopen-failed-cannot-loca
http://stackoverflow.com/questions/15872254/android-ndk-warning-app-platform-android-9-is-larger-than-androidminsdkversio
https://github.com/cocos2d/cocos2d-js/issues/631

Problems

コンパイルしたapkを実機にインストールして実行すると...

問題が発生したため、${appname}を終了します

というダイアログが出て終了する

エラーログはこんな感じ

...
E/dalvikvm(19125): dlopen("/data/app-lib/org.cocos2dx.GameBase-2/libcocos2dlua.so") failed: dlopen failed: cannot locate symbol "signal" referenced by "libcocos2dlua.so"...
D/AndroidRuntime(19125): Shutting down VM
W/dalvikvm(19125): threadid=1: thread exiting with uncaught exception (group=0x41668d58)
E/AndroidRuntime(19125): FATAL EXCEPTION: main
E/AndroidRuntime(19125): Process: org.cocos2dx.GameBase, PID: 19125
E/AndroidRuntime(19125): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "signal" referenced by "libcocos2dlua.so"...
E/AndroidRuntime(19125):        at java.lang.Runtime.loadLibrary(Runtime.java:364)
E/AndroidRuntime(19125):        at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime(19125):        at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
E/AndroidRuntime(19125):        at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
E/AndroidRuntime(19125):        at android.app.Activity.performCreate(Activity.java:5245)
E/AndroidRuntime(19125):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime(19125):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2179)
E/AndroidRuntime(19125):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2292)
E/AndroidRuntime(19125):        at android.app.ActivityThread.access$800(ActivityThread.java:149)
E/AndroidRuntime(19125):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
E/AndroidRuntime(19125):        at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(19125):        at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(19125):        at android.app.ActivityThread.main(ActivityThread.java:5265)
E/AndroidRuntime(19125):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(19125):        at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(19125):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
E/AndroidRuntime(19125):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:639)
E/AndroidRuntime(19125):        at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  860):   Force finishing activity org.cocos2dx.GameBase/org.cocos2dx.lua.AppActivity
I/ActivityManager(  860): Config changes=480 {1.0 440mcc20mnc ja_JP ldltr sw360dp w360dp h566dp 240dpi nrml port finger -keyb/v/h -nav/h s.26}
I/Choreographer( 1423): Skipped 32 frames!  The application may be doing too much work on its main thread.
I/InputReader(  860): Reconfiguring input devices.  changes=0x00000004
I/InputReader(  860): Device reconfigured: id=7, name='cyttsp5_mt', size 540x960, orientation 0, mode 1, display id 0
W/ContextImpl(  860): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1139 com.android.server.am.AppErrorDialog.<init>:114 com.android.server.am.ActivityManagerService$2.handleMessage:1211 android.os.Handler.dispatchMessage:102 android.os.Looper.loop:136
...

さらによく見るとこんな感じのワーニングがndk-build実行時に出てた

Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml

Solutions

Application.mkに以下を追記する

Application.mk
APP_PLATFORM := android-9

すると、今度はコンパイル時に以下のエラーが発生する

[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp
/Users/tanishi/Documents/GameBase/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/javaactivity-android.cpp: In function 'void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv*, jobject, jint, jint)':
/Users/tanishi/Documents/GameBase/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/javaactivity-android.cpp:101:34: warning: 'void cocos2d::DrawPrimitives::init()' is deprecated (declared at /Users/tanishi/Documents/GameBase/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/../../2d/CCDrawingPrimitives.h:88) [-Wdeprecated-declarations]
         cocos2d::DrawPrimitives::init();
                                  ^
/Users/tanishi/Documents/GameBase/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/javaactivity-android.cpp:101:39: warning: 'void cocos2d::DrawPrimitives::init()' is deprecated (declared at /Users/tanishi/Documents/GameBase/frameworks/runtime-src/proj.android/../../cocos2d-x/cocos//platform/android/../../2d/CCDrawingPrimitives.h:88) [-Wdeprecated-declarations]
         cocos2d::DrawPrimitives::init();
                                       ^
[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxHelper.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= JniHelper.cpp
make: *** No rule to make target `/Users/tanishi/Library/Android/ndk/sources/android/cpufeatures/cpu-features.c', needed by `obj/local/armeabi/objs-debug/cpufeatures/cpu-features.o'.  Stop.
make: *** Waiting for unfinished jobs....
[armeabi] Compile++ thumb: cocos2dxandroid_static <= TouchesJni.cpp
make: Leaving directory `/Users/tanishi/Documents/GameBase/frameworks/runtime-src/proj.android'
Error running command, return code: 2.

cpkfeaturesのオブジェクトファイルを削除する

$ find . -name cpu-features.o* | rm -f

これでようやくコンパイルが通って起動できた

Screenshot_2016-09-10-23-16-16.png

Impressions

これって結構クリティカルなバグだよな...
もしかして困ってるの俺だけなのか?

解決に半日以上かかったけど、
stackoverflowさんはやっぱり神だわ

tani-shi
フリーのソシャゲ開発のエンジニアです。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした