IllegalArgumentException: Unable to find library: cocos2dcpp on Nexus 5

Hello!

I’m trying to set up my Cocos2d-x 3.0 beta 2 environment and came across this issue. Eclipse shows no errors, the project builds just fine. Nevertheless, whenever I try to run, the app installs on the phone, then crashes.

I am trying to install in on a Nexus 5 - not an emulator( i’ve searched a bit before posting. I saw that some users had this problem when they used an emulator, but i’m building for a real device)

Other data:
Ndk : r9
Phone Android Version: 4.4(api 19)
IDE : Eclipse
OS : Ubuntu 13.10
Cocos version : Cocos2d-x 3.0 beta 2

I’ve set the following in $PATH:
NDK_HOME : /home/myUsername/Development/android-ndk
ANDROID_SDK : /home/myUsername/Development/android-sdk

Also, in Eclipse I have:
COCOS2DX : /home/myUsername/Development/cocos2d-x-3

Where “android-sdk” and “android-ndk” are the root of the folders for the two respective development kits, “cocos2d-x-3” the root of my cocos framework folder.

I also have to mention that I managed to build and make the sample apps work just fine, using cocos2dx v2. Now I migrated to v3beta2 since v2 si going to become outdated soon…

Last but not least, I did import libcocos2dx in eclipse, and added it as a dependency for the project.

It appears like this when I got o Project–>Properties–>Android, I have

../../../../../cocos/2d/platform/android/java                   libcocos2dx

and Android 4.4.2 checked in the top view.

Here’s the full stacktrace:

03-14 09:20:31.562: E/AndroidRuntime(30200): FATAL EXCEPTION: main
03-14 09:20:31.562: E/AndroidRuntime(30200): Process: com.MyCompany.AwesomeGame, PID: 30200
03-14 09:20:31.562: E/AndroidRuntime(30200): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MyCompany.AwesomeGame/org.cocos2dx.cpp.Cocos2dxActivity}: java.lang.IllegalArgumentException: Unable to find native library: cocos2dcpp
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.os.Handler.dispatchMessage(Handler.java:102)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.os.Looper.loop(Looper.java:136)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.ActivityThread.main(ActivityThread.java:5017)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at java.lang.reflect.Method.invokeNative(Native Method)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at java.lang.reflect.Method.invoke(Method.java:515)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at dalvik.system.NativeStart.main(Native Method)
03-14 09:20:31.562: E/AndroidRuntime(30200): Caused by: java.lang.IllegalArgumentException: Unable to find native library: cocos2dcpp
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.NativeActivity.onCreate(NativeActivity.java:171)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at org.cocos2dx.cpp.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:11)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.Activity.performCreate(Activity.java:5231)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-14 09:20:31.562: E/AndroidRuntime(30200): 	... 11 more

The project “AwesomeGame” was generated using the sample generator, mentioned here: http://www.cocos2d-x.org/forums/6/topics/42701 . I generated it using the command in that tutorial, eg:

python create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language cpp

I changed the minimum/target sdk’s of the cocos project/my project to android api 14, but I don’t think this is the cause of this problem. I’m only interested for support for api level 14+ as of now.

So…what might I be missing? /sigh

Thank you for your time!


cocos_error_logs.zip (0.7 KB)

did you compile c++ code?

in your project, open Manifest file, you will find out

        <meta-data android:name="android.app.lib_name"
                   android:value="your_native_lib" />

change your_native_lib by your native lib and run project.
good luck, :slight_smile:

I’m at work now, but I’ll come back with an edit as soon as I’ll try this at home!

Thanks for the reply tavadung12! Hope this works :smiley: