简体   繁体   中英

Cocos2D Project Not Working on Android Studio

I just started a project in cocos studio and I want to build it for android .... but after I just opened with the emulator it just doesn't work.

This is my logcat:

02-14 07:43:35.805 3796-3796/org.cocos2dx.Example E/AndroidRuntime: FATAL EXCEPTION: main Process: org.cocos2dx.Example, PID: 3796 java.lang.UnsatisfiedLinkError: Couldn't load cocos2djs from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.cocos2dx.Example-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.cocos2dx.Example-2, /system/lib]]]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java:358) at java.lang.System.loadLibrary(System.java:526) at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248) at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:263) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access$800(ActivityThr ead.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)

And this is the activity:

> protected void onLoadNativeLibraries() {
>         try {
>             ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),
> PackageManager.GET_META_DATA);
>             Bundle bundle = ai.metaData;
>             String libName = bundle.getString("android.app.lib_name");
>             System.loadLibrary(libName);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }


// ===========================================================
// Constructors
// ===========================================================

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CocosPlayClient.init(this, false);

    onLoadNativeLibraries();

    sContext = this;
    this.mHandler = new Cocos2dxHandler(this);

Try to add this static function to your Activity.

static
{
    System.loadLibrary("cocos2dcpp");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM