Open xdeop opened 7 years ago
On first launch, the app downloads an obb file (native Android Activity) from google play, and after validating the download, it starts the Cocos2dxActivity.
I think it is caused by it. Could you please tell me how did you do it in detail?
Hi, I've developed a native Activity which handles the download of the .obb file (zip extension changed) if it doesn't exists. After the download (first launch), or if the file exists (next launches), I start the verification of the file and if is correct, I start the AppActivity (Cocos2dxActivity). I've followed google developers instructions and samples (https://developer.android.com/google/play/expansion-files.html) and this process is working fine. On the first launch, when the app crashes (after the download) I've debugged the Cocos2dxActivity and it seems all correct. In the Cocos2dxHelper.init(this):
154 Cocos2dxHelper.nativeSetApkPath(Cocos2dxHelper.getAssetsPath()); 155 Log.d("Cocos2dxHelper", "sAssetsPath: " + Cocos2dxHelper.sAssetsPath.toString());
181 try { 182 Cocos2dxHelper.sOBBFile = APKExpansionSupport.getAPKExpansionZipFile(Cocos2dxActivity.getContext(), versionCode, 0); 183 Log.d("Cocos2dxHelper", "sOBBFile: " + Cocos2dxHelper.sOBBFile.toString()); 184 } catch (IOException e) { 185 e.printStackTrace(); 186 }
Cocos2dxHelper.sAssetsPath contains the correct path to the obb file and Cocos2dxHelper.sOBBFile contains the ZipResourceFile.
With this debugging results, everything looks ok to me... I'm unable to figure out where the error is!
Any help please?
Thanks.
Sorry, i don't have similar experience about using native activity to start cocos2d-x activity. May be you can post a ticket in the forum, other developers may give some help.
/data/app/com.protectfive.cocos2dx.sample-1/lib/arm/libMyGame.so (cocos2d::GLProgram::reset()+48)
Do you know the which line cause the issue?
Hi, I've found the solution to avoid the crash, although I don't understand what is causing it.
Because the download is managed with a service and updates the current Activity with a pendingIntent, if I start de Cocos2dxAcitivity without the intent flag Intent.FLAG_ACTIVITY_SINGLE_TOP, Android starts the Cocos2dxActivity in a new task and this is causing the crash.
Do you have any explanation of what may be the cause of the crash?
Sorry, i have not idea about it. Could you please find which line cause the crash?
Hi, I don't know the exact line that causes the crash due to the difficulty to debug or trace errors in the Android version of the cocos2dx app. Is there a way to develop and debug it with Android Studio?
The crash is occurring before the first's scene init method, after director->runWithScene(scene);
You can try this PR https://github.com/cocos2d/cocos2d-x/pull/15676. I will merge it in this version or next version.
On first start of application, it crashes with the following log:
02-13 17:53:11.909 122-122/? I/DEBUG: Revision: '0' 02-13 17:53:11.909 122-122/? I/DEBUG: ABI: 'arm' 02-13 17:53:11.909 122-122/? I/DEBUG: pid: 24807, tid: 25863, name: GLThread 1159 >>> com.protectfive.cocos2dx.sample <<< 02-13 17:53:11.910 122-122/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 02-13 17:53:11.939 122-122/? I/DEBUG: backtrace: 02-13 17:53:11.940 122-122/? I/DEBUG: #00 pc 00788130 /data/app/com.protectfive.cocos2dx.sample-1/lib/arm/libMyGame.so (cocos2d::GLProgram::reset()+48) 02-13 17:53:11.940 122-122/? I/DEBUG: #01 pc 00791948 /data/app/com.protectfive.cocos2dx.sample-1/lib/arm/libMyGame.so (cocos2d::GLProgramCache::reloadDefaultGLPrograms()+2652) 02-13 17:53:11.940 122-122/? I/DEBUG: #02 pc 0052d4e1 /data/app/com.protectfive.cocos2dx.sample-1/lib/arm/libMyGame.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit+184)
The following launches, the app is working fine.
On first launch, the app downloads an obb file (native Android Activity) from google play, and after validating the download, it starts the Cocos2dxActivity.
I'm compiling the project with the following Android.mk file:
APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic APP_ABI := armeabi-v7a arm64-v8a x86 ifeq ($(NDK_DEBUG),1) APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 APP_OPTIM := debug else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release endif
How can I fix this problem? How can I find out what produces the crash?
Thanks!