Crash in HelloWorld Project Android

hi,
I am new to cocos2dx and porting ios project to android platform. i made HelloWorld project from command line and it runnig successfully on my device.
Then i added ios game classes in android.mk file and it build successfully. I dont change Appdelegate class and helloWorld class, so it loaded hello world scene in AppDelegate class . But when i run this in my device it crashes but running good in IOS device.
I am using cocos2dx v3.3 with ndk 9d and 10c and device i used is Nexus 5 running with Android 5.1. My target platform of project is Android 4.4w. I used ndk-stack and it shows like-

********** Crash dump: **********

Build fingerprint: ‘google/hammerhead/hammerhead:5.1/LMY47I/1767468:user/release-keys’
pid: 26538, tid: 26538, name: aybuff.BOWFinal >>> com.playbuff.BOWFinal <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Stack frame #00 pc 0096479c /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (_JavaVM::GetEnv(void**, int)+28): Routine ??
??:0
Stack frame #01 pc 00964f90 /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (cocos2d::JniHelper::cacheEnv(JavaVM*)+44): Routine ??
??:0
Stack frame #02 pc 00965108 /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (cocos2d::JniHelper::getEnv()+72): Routine ??
??:0
Stack frame #03 pc 009652b8 /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (cocos2d::JniHelper::getStaticMethodInfo(cocos2d::JniMethodInfo
&, char const*, char const*, char const*)+72): Routine ??
??:0
Stack frame #04 pc 00963840 /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (getPackageNameJNI()+108): Routine ??
??:0
Stack frame #05 pc 00aec6ac /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (cocos2d::UserDefault::initXMLFilePath()+56): Routine ??
??:0
Stack frame #06 pc 00aec57c /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so (cocos2d::UserDefault::getInstance()+16): Routine ??
??:0
Stack frame #07 pc 0059d2e4 /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so: Routine TIFFFreeDirectory at ??:?
Stack frame #08 pc 0059d3b0 /data/app/com.playbuff.BOWFinal-1/lib/arm/libcocos2dcpp.so: Routine TIFFFreeDirectory at ??:?
Stack frame #09 pc 000015b5 /system/bin/linker (__dl__ZN6soinfo12CallFunctionEPKcPFvvE+44)
Stack frame #10 pc 00001689 /system/bin/linker (__dl__ZN6soinfo9CallArrayEPKcPPFvvEjb+140)
Stack frame #11 pc 0000185f /system/bin/linker (__dl__ZN6soinfo16CallConstructorsEv+142)
Stack frame #12 pc 00003259 /system/bin/linker (__dl__Z9do_dlopenPKciPK17android_dlextinfo+192)
Stack frame #13 pc 00000f1d /system/bin/linker (__dl__ZL10dlopen_extPKciPK17android_dlextinfo+24)
Stack frame #14 pc 001e102d /system/lib/libart.so (art::JavaVMExt::LoadNativeLibrary(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, art::Handleart::mirror::ClassLoader, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >)+544)
Stack frame #15 pc 00207b13 /system/lib/libart.so (art::Runtime_nativeLoad(_JNIEnv
, _jclass*, _jstring*, _jobject*, _jstring*)+514)
Stack frame #16 pc 000797f5 /data/dalvik-cache/arm/system@framework@boot.oat

Please help.

@Sankalp, was it solved somehow?

Hey @Sankalp

were you able to solve the issue yet ?

Anybody got a solution for the issue in question?
@pabitrapadhy @vedi @Sankalp @SonarSystems @slackmoehrle @energyy @yinjimmy @nite

I am having the same issue.
As far as I understand, the call sequence is something like -> UserDefault::getInstance() ---> initXMLFilePath() --> getPackageNameJNI() and crash. There seems to be some difficulty while making call to Java from C++ through JNI.

FYI, this is working for some UserDefault keys and crashing for some others.

Can you post the stack trace for the crash?

Backtrace as follows:

backtrace:
native: pc 000000000048e048 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_ZN7_JavaVM6GetEnvEPPvi+28)
native: pc 000000000048e814 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d9JniHelper8cacheEnvEP7_JavaVM+68)
native: pc 000000000048e9b0 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d9JniHelper6getEnvEv+72)
native: pc 000000000048eb90 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (ZN7cocos2d9JniHelper19getStaticMethodInfoERNS_14JniMethodInfo_EPKcS4_S4+72)
native: pc 000000000048ba60 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_Z17getPackageNameJNIv+132)
native: pc 000000000063a364 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d11UserDefault15initXMLFilePathEv+72)
native: pc 000000000063a250 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_ZN7cocos2d11UserDefault11getInstanceEv+36)
native: pc 000000000046de44 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so (_ZN6PlayerC2Ev+100)
native: pc 00000000004706cc /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so
native: pc 0000000000470724 /data/app/com.spark.atom2048-2/lib/arm/libcocos2dcpp.so
native: pc 0000000000002469 /system/bin/linker (__dl__ZN6soinfo13call_functionEPKcPFvvE+48)
native: pc 0000000000002535 /system/bin/linker (__dl__ZN6soinfo10call_arrayEPKcPPFvvEjb+136)
native: pc 00000000000026f9 /system/bin/linker (__dl__ZN6soinfo17call_constructorsEv+160)
native: pc 000000000000610d /system/bin/linker (__dl__Z9do_dlopenPKciPK17android_dlextinfo+224)
native: pc 0000000000001c99 /system/bin/linker (__dl_dlopen+20)
native: pc 00000000002500e5 /system/lib/libart.so (ZN3art9JavaVMExt17LoadNativeLibraryEP7_JNIEnvRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEP8_jobjectPS9+600)
native: pc 00000000002c244f /system/lib/libart.so (ZN3artL18Runtime_nativeLoadEP7_JNIEnvP7_jclassP8_jstringP8_jobjectS5+178)
native: pc 0000000002232b8d /system/framework/arm/boot.oat

@nite, btw I have resolved this issue by not calling/utilizing UserDefault (to save or retrieve key-data) in a constructor of any class (the classes which I defined).

For example, in my previous message “Backtrace” on this thread, you can notice that UserDefault is called from Player class constructor. To resolve this issue, I moved the UserDefault call to another function Player::Initialize which is called after the object of player is created. And this resolved the issue for me.

I am using cocos2d-x v3.10.

CC: @Sankalp @vedi @pabitrapadhy.