How can I debug Cocos2d-x project in Android Studio? - android

Environment: Cocos2d-x 3.9, Android Studio priview 2.0, ndk r10e (64-bit), win10(64bit).
Cocos-console seems to use NDK to compile all my cpp component into one libcocos2dcpp.so file. I managed to get my app compiled. It ran well on win32, but crashed on Android.
I/DEBUG: Build fingerprint: 'samsung/h3gzc/hlte:5.0/LRX21V/N9006ZCUGOH2:user/release-keys'
I/DEBUG: Revision: '8'
I/DEBUG: ABI: 'arm'
I/DEBUG: pid: 2561, tid: 2561, name: Zzzen.YourWorld >>> com.github.Zzzen.YourWorld <<<
I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
I/DEBUG: r0 b4f512b0 r1 1fffffff r2 2e7e0d8d r3 b4f512b0
I/DEBUG: r4 00000043 r5 b4f18228 r6 a20f99e4 r7 00000000
I/DEBUG: r8 b4f07800 r9 b4efac64 sl bef10b58 fp bef10984
I/DEBUG: ip a275abd0 sp bef10978 lr a20f9a10 pc 00000000 cpsr 600f0010
I/DEBUG: #00 pc 00000000 <unknown>
I/DEBUG: #01 pc 00352a0c /data/app/com.github.Zzzen.YourWorld-1/lib/arm/libcocos2dcpp.so (JNI_OnLoad+40)
I/DEBUG: #02 pc 001d5357 /system/lib/libart.so (art::JavaVMExt::LoadNativeLibrary(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, art::Handle<art::mirror::ClassLoader>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+1478)
I/DEBUG: #03 pc 001fd061 /system/lib/libart.so (art::Runtime_nativeLoad(_JNIEnv*, _jclass*, _jstring*, _jobject*, _jstring*)+548)
I/DEBUG: #04 pc 00019811 /system/framework/arm/boot.oat
So I used addr2line to see what's at 00352a0c. However, It just showed JNI_OnLoad. Should I add assertions after creating a sprite in case Sprite::create may return nullptr?

I often use Cocos2d-x 's log function to find out where the app crash.
(e.g. log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);)
You can filter the log messages by 'cocos2d' in Android studio to see all logs about your cocos2d-x app.

Related

My Game crash in Samsung gives error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4

My game facing this crash sometime in particular Samsung Device, and i dint know what to do for this type of problem. I have already import app compatibility v7 in my project.
Build fingerprint: 'samsung/grandppltedtvvj/grandppltedtv:6.0.1/MMB29T/G532MTVJU1AQB1:user/release-keys'
Revision: '5'
ABI: 'arm'
pid: 22325, tid: 22341, name: GLThread 42320 >>> com.abc.candy <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
r0 00000000 r1 00000000 r2 00000000 r3 00000000
r4 00000001 r5 00000001 r6 00000001 r7 00000001
r8 00000001 r9 b31a1f00 sl 00000000 fp b2f402bc
ip b2f3fec4 sp b2f402a8 lr 9edd50d4 pc 9ee82900 cpsr 200f0010
backtrace:
#00 pc 0062e900 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d3Ref6retainEv+20)
#01 pc 005810d0 /data/app/com.abc.candy2-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6Sprite14setSpriteFrameEPNS_11SpriteFrameE+92)
#02 pc 00580fc4 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d6Sprite14setSpriteFrameERKSs+616)
#03 pc 0041c23c /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN9GameScene15generateSpecialEP5CandySsii+844)
#04 pc 00425e18 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so
#05 pc 00432cfc /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so
#06 pc 004dba4c /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvvEEclEv+60)
#07 pc 004dabec /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8CallFunc7executeEv+204)
#08 pc 004dab14 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8CallFunc6updateEf+40)
#09 pc 004df2bc /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8Sequence6updateEf+1140)
#10 pc 004de3a8 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d14ActionInterval4stepEf+584)
#11 pc 0073c4f4 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d13ActionManager6updateEf+244)
#12 pc 00603000 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZZN7cocos2d9Scheduler14scheduleUpdateINS_13ActionManagerEEEvPT_ibENKUlfE_clEf+36)
#13 pc 00604b9c /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZNSt17_Function_handlerIFvfEZN7cocos2d9Scheduler14scheduleUpdateINS1_13ActionManagerEEEvPT_ibEUlfE_E9_M_invokeERKSt9_Any_dataf+60)
#14 pc 004ea360 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZNKSt8functionIFvfEEclEf+88)
#15 pc 0063aeac /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d9Scheduler6updateEf+172)
#16 pc 005fe90c /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d8Director9drawSceneEv+160)
#17 pc 00602d74 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (_ZN7cocos2d19DisplayLinkDirector8mainLoopEv+136)
#18 pc 004638a0 /data/app/com.abc.candy-1/lib/arm/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender+40)
#19 pc 006da6a5 /data/app/com.abc.candy-1/oat/arm/base.odex (offset 0x512000)
Build fingerprint: 'samsung/j23gdd/j23g:5.1.1/LMY48B/J200HXXU0APK1:user/release-keys'
Revision: '2'
ABI: 'arm'
pid: 22292, tid: 22310, name: GLThread 3374 >>> com.abc.candy <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20
r0 9f21dc00 r1 00000078 r2 00000078 r3 00000000
r4 a3396b5c r5 a2dcbd5c r6 9f21dc00 r7 9f280184
r8 010f03ce r9 b4428400 sl 00000000 fp a264e854
ip 9f21dc00 sp a264e800 lr a2c68d48 pc a2c68b4c cpsr 800f0010
All this crash comes in Samsung device not in other device.
You can check the exact line number where crash occurs by using following :-
When you get errors like this on the LogCat, they are saved on $PROJECT_PATH/obj/local/armeabi where $PROJECT_PATH is the path to your cocos2d-x android project. To symbolicate the messages to something understandable, you can use the ndk-stack tool.
Open up the Terminal (or Cygwin, not sure though) and type in
cd $ANDROID_NDK
adb logcat | ./ndk-stack -sym $PROJECT_PATH/obj/local/armeabi
where:
$ANDROID_NDK is the path to your android NDK
$PROJECT_PATH is the path to your cocos2d-x android project

Xamarin Android Native crash at /system/lib/libc.so

I released an application and I get these native crashes especially from Galaxy J2(90% of crashes). Users say when App starts it is an immidiate crash. So far I got 25 crashes and I cant even find what is wrong to solve. I am unable to debug on Galaxy J2 but every device that I run the application works with no problem. Here is crash report.
Revision: '4'
ABI: 'arm'
pid: 4110, tid: 4110, name: sth.someappname >>> com.sth.someappname <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '* Assertion at /Users/builder/data/lanes/3511/b5fafb24/source/mono/mono/mini/method-to-ir.c:12777, condition `mono_arch_opcode_supported (OP_ATOMIC_STORE_I4)' not met
'
r0 00000000 r1 0000100e r2 00000006 r3 00000000
r4 b6f14e38 r5 00000006 r6 00000002 r7 0000010c
r8 b4542cac r9 00000000 sl b47709b8 fp bef19930
ip 0000100e sp bef198d8 lr b6d67e79 pc b6d8bb5c cpsr 600e0010
backtrace:
#00 pc 0003bb5c /system/lib/libc.so (tgkill+12)
#01 pc 00017e75 /system/lib/libc.so (pthread_kill+52)
#02 pc 00018a8b /system/lib/libc.so (raise+10)
#03 pc 00015325 /system/lib/libc.so (__libc_android_abort+36)
#04 pc 00012fb0 /system/lib/libc.so (abort+4)
#05 pc 00291cdc /data/app/com.sth.someappname-1/lib/arm/libmonosgen-2.0.so
Any idea?
I got rid of this issue by removing thread.sleep() function from splash screen. Then I decided to remove all of them from project.

My Android drawing application is crashing somewhere in native code

my Android vector-drawing application is uncommonly crashing somewhere in native code. I cannot catch the crash with Java try-catch block, I can see it only in the Google Play Developer console in the "Crashes and ANR's" section.
Here is the trace from the console:
Build fingerprint: 'samsung/kltexx/klte:5.0/LRX21T/G900FXXU1BOJ1:user/release-keys'
Revision: '14'
ABI: 'arm'
pid: 31153, tid: 31153, name: ... >>> ... <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x65eb3cf4
r0 65eb3cf4 r1 a75f2764 r2 7fffffff r3 be8c15ec
r4 af56a838 r5 7fffffff r6 be8c1570 r7 b4efac6c
r8 b4efac6c r9 be8c15c0 sl 00000000 fp be8c1590
ip b4efac6c sp be8c1528 lr a75f2760 pc b5a60ae6 cpsr a0000030
backtrace:
#00 pc 000ecae6 /system/lib/libskia.so (SkRegion::Oper(SkRegion const&, SkRegion const&, SkRegion::Op, SkRegion*)+861)
#01 pc 000ecc67 /system/lib/libskia.so (SkRegion::op(SkRegion const&, SkIRect const&, SkRegion::Op)+28)
#02 pc 000969df /system/lib/libandroid_runtime.so
#03 pc 00ba8897 /system/framework/arm/boot.oat
Can anyone help me? How can I locate the problematic place in my code?
Thank you!
The reason of the crash was my own fault:
I'm using the android.graphics.Region class in my application. I'm calling the Region.op() method and a problem was that I was calling the method from two different threads.
These operations aren't thread-safe, so that was the reason of the crashes.

libGLESv2_adreno.so game crash in Galaxy Note 4 and Lollipop 5.0

Some users of my game that are trying to play it in a Samsung Galaxy Note 4 updated to Android Lollipop 5.0 are experiencing a game crash at startup:
Build fingerprint: 'samsung/trlteuc/trlteatt:5.0.1/LRX22C/N910AUCU1COC2:user/release-keys'
Revision: '12'
ABI: 'arm'
pid: 20911, tid: 20927, name: GLThread 270611 >>> com.mangoprotocol.psychotic.mechanika <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
r0 00000000 r1 000051bf r2 00000006 r3 00000000
r4 b39ffdb8 r5 00000006 r6 00000002 r7 0000010c
r8 a0e1a140 r9 00000000 sl 00000001 fp aa934c40
ip 000051bf sp b39ff830 lr b6e8cff5 pc b6eb0998 cpsr 600b0010
backtrace:
#00 pc 00037998 /system/lib/libc.so (tgkill+12)
#01 pc 00013ff1 /system/lib/libc.so (pthread_kill+52)
#02 pc 00014c0f /system/lib/libc.so (raise+10)
#03 pc 00011531 /system/lib/libc.so (__libc_android_abort+36)
#04 pc 0000fcbc /system/lib/libc.so (abort+4)
#05 pc 00001259 /system/lib/libstdc++.so
#06 pc 00000afb /system/lib/libstdc++.so (__cxa_pure_virtual+6)
#07 pc 000e4595 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxGlObject::DecRefCount(EsxContext*)+28)
#08 pc 000b4b67 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::GlUseProgram(unsigned int)+150)
#09 pc 000e02d3 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlUseProgram(EsxDispatch*, unsigned int)+34)
#10 pc 000abd75 /system/vendor/lib/egl/libGLESv2_adreno.so (glUseProgram+44)
#11 pc 002e9887 /data/dalvik-cache/arm/data#app#com.mangoprotocol.psychotic.mechanika-1#base.apk#classes.dex
I don't know if this is related to the OpenGL ES driver for the GPU (Adreno 420) if it is a more general issue with the OS (Android Lollipop 5.0), or if it has something to do with libGDX (the game framework I'm using). What I know is that the games works like a charm in a Nexus 6 (also with Adreno 420) updated to Lollipop 5.1.
Do you have any idea about how to solve this issue or how to work around it?

Multiple view Activity Transition

Android Lolipop has an api that allows for easy transitions between shared elements in different activities.
Activity transitions
It looks like this api doesn't support a transition with multiple views. Is there a way to do this using the same api?
EDIT
Following the advice from #pskink I use a different method
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(this, Pair.create((View)view, "viewPager"), Pair.create((View) fab, "fab"));
startActivity(intent, options.toBundle());
This worked fine from ActivityA to ActivityB but hitting the back button results in this stacktrace
A/OpenGLRenderer(17305): requireSurface() called but no surface set!
A/libc(17305): Fatal signal 6 (SIGABRT), code -6 in tid 17349(RenderThread)
Build fingerprint: 'google/hammerhead/hammerhead:5.0/LRX21O/1570415:user/release-keys'
Revision: '11'
ABI: 'arm'
pid: 3364, tid: 3414, name: RenderThread >>> com.example.package <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'requireSurface() called but no surface set!'
r0 00000000 r1 00000d56 r2 00000006 r3 00000000
r4 9e9b5db8 r5 00000006 r6 0000003e r7 0000010c
r8 ac39bacc r9 9e9b5d08 sl 9e9b5d00 fp ac39bb08
ip 00000d56 sp 9e9b5858 lr b6f1faf9 pc b6f435d4 cpsr 600f0010
backtrace:
#00 pc 0003a5d4 /system/lib/libc.so (tgkill+12)
#01 pc 00016af5 /system/lib/libc.so (pthread_kill+52)
#02 pc 00017707 /system/lib/libc.so (raise+10)
#03 pc 00013f75 /system/lib/libc.so (__libc_android_abort+36)
#04 pc 00012a3c /system/lib/libc.so (abort+4)
#05 pc 00007a59 /system/lib/libcutils.so (__android_log_assert+88)
#06 pc 0003b61f /system/lib/libhwui.so
#07 pc 0003b971 /system/lib/libhwui.so
#08 pc 0003cf8d /system/lib/libhwui.so
#09 pc 0003cea5 /system/lib/libhwui.so
#10 pc 0003d885 /system/lib/libhwui.so
#11 pc 0003e27b /system/lib/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+66)
#12 pc 000104d5 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+112)
#13 pc 0005df4d /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+72)
#14 pc 00010045 /system/lib/libutils.so
#15 pc 000162e3 /system/lib/libc.so (__pthread_start(void*)+30)
#16 pc 000142d3 /system/lib/libc.so (__start_thread+6)
EDIT2
The only logs that I receive when I filter by package name are below. The first log looks like it is coming from render script, I posted the log above as I thought it is related.
A/OpenGLRenderer(11128): requireSurface() called but no surface set!
A/libc(11128): Fatal signal 6 (SIGABRT), code -6 in tid 11219
(RenderThread)
I/ci(11358): Making Creator dynamically
W/ResourcesManager(11358): Asset path
'/system/framework/com.android.media.remotedisplay.jar' does not exist
or contains no
W/ResourcesManager(11358): Asset path
'/system/framework/com.android.location.provider.jar' does not exist
or contains no
EDIT3
So I was able to get this to work by disabling the mapfragment that was on activityA. I am still investigating why this would happen

Categories

Resources