0

I'm having horrible troubles migrating to Cocos2d-x 3.x. Everything works perfectly on iOS (of course it does...) but crashes during startup on Android.

The error I'm getting is this:

********** Crash dump: **********
Build fingerprint: 'samsung/yakjuxw/maguro:4.2.1/JOP40D/I9250XWMA2:user/release-keys'
pid: 22977, tid: 22977, name: WOOOHOO  >>> WOOOHOO <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
Stack frame #00  pc 00a33fd0  /data/app-lib/WOOOHOO-1/libcocos2dcpp.so (_JavaVM::GetEnv(void**, int)+28)
Stack frame #01  pc 00a34608  /data/app-lib/WOOOHOO-1/libcocos2dcpp.so (cocos2d::JniHelper::cacheEnv(_JavaVM*)+44)
Crash dump is completed

What I've tried

First I tried running the cpp tests that come with Cocos2d-x (from a clean extraction of cocos2d-x-3.2.zip). They work fine.

Then I tried creating a new project from scratch using the cocos command. It compiles and WORKS. I tried this using both 3.1 and 3.2.

THEN I tried adding my own sources to this project. This is where things get weird. I can add some of the files but adding them all does not work. EVEN WHEN THE CODE IS NEVER CALLED FROM THE DEFAULT AppDelegate... The same thing happens in both 3.1 and 3.2.

Modifications to Android.mk

The only modification I've made to the proj.android/jni/Android.mk file is adding -fexceptions to APP_CPPFLAGS.

Modifications to Android.mk

The only modifications I've made to the proj.android/jni/Android.mk file are adding these lines to search for code

CPP_FILE_LIST := $(LOCAL_PATH)/hellocpp/main.cpp
CPP_FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
CPP_FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/**/*.cpp)
CPP_FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/**/**/*.cpp)
CPP_FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/libs/jansson-2.6/*.c)
LOCAL_SRC_FILES := $(CPP_FILE_LIST:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
                    $(LOCAL_PATH)/../../Classes/map \
                    $(LOCAL_PATH)/../../Classes/menus \
                    $(LOCAL_PATH)/../../Classes/util \
                    $(LOCAL_PATH)/../../Classes/worlds \
                    $(LOCAL_PATH)/../../Classes/libs/jansson-2.6

and uncommenting

LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static

$(call import-module,editor-support/cocostudio)

because I use some widgets from the new ui namespace.

What is wrong? I can't figure this out...

Sebastian Ärleryd
  • 1,774
  • 14
  • 19

1 Answers1

1

Have you tried debug build for Android? https://stackoverflow.com/a/24351602/629118 You may get stack trace of the SIGSEGV.

THEN I tried adding my own sources to this project. This is where things get weird. I can add some of the files but adding them all does not work. EVEN WHEN THE CODE IS NEVER CALLED FROM THE DEFAULT AppDelegate...

It sounds your sources might have a problem. It may happen even though the other part of your app never called the sources. Global constructor is called automatically. Also, due to Android runtime, static variables are never cleared when restarting app. So divide and conquer. Add your code as little as possible, build and launch. repeat it.

Community
  • 1
  • 1
Kazuki Sakamoto
  • 13,929
  • 2
  • 34
  • 96
  • WONDERFUL! Thank you so much! :) I had some global variables in an anonymous namespace that, when initialized, called a Cocos2d-x library function that was not ready yet. :) – Sebastian Ärleryd Aug 03 '14 at 01:15