Crash in Android Native while changing to new Activity

前端 未结 1 964
挽巷
挽巷 2021-01-24 21:30

My application is unable to open OpenFeint dashboard methods. The implementation of the native c++ libraries uses cocos2d-x as a graphic library, but it has a handler and a wrap

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-24 22:23

    The answer was easy but complex. When the app changes to a new activity, the nativeOnPause method from cocos2d-x MessageJNI is called. This method is supposed to call a CCApplication::sharedApplication(), but one of my classes had previously called the CCApplication destructor, which cleared the shared singleton to null.

    Even though the answer is easy to fix and project specific, I am going to give some advice on what made me find it. Keep in mind that all my tools are windows and cygwin.

    First, make Eclipse do the ndk-builds for you on clean.

    Rightclick your Project-> Properties -> C/C++ Build. Builder Settings tab, Command

      C:\NVPACK\cygwin\bin\bash.exe -c "cd /cygdrive/path/to/project && ./build_script.sh"
    

    Second, setup your debugger.

    Using this tutorial. It may take some time and attempts to get there but it is worth it. My adb-server call script is

    export ANDROID_NDK_ROOT=/cygdrive/c/NVPACK/android-ndk-r6b/
    cd $ANDROID_NDK_ROOT
    ./ndk-gdb-eclipse --adb=/cygdrive/c/NVPACK/android-sdk-windows/platform-tools/adb     --project=/cygdrive/c/project/path --force --verbose
    

    Third, set your logcat in verbose.

    UPDATE: This last step can now be skipped as latest versions of Logcat output the class and line for the whole stacktrace.

    You will get long stacktraces like the one in my question. To check where the stacktrace errors point follow this other tutorial. My script to access the library is

    C:\NVPACK\android-ndk-r6b\toolchains\x86-4.4.3\prebuilt\windows\bin\i686-android-linux-addr2line.exe -C -f -e c:\path\to\project\libMyLib.so
    

    0 讨论(0)
提交回复
热议问题