Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ndk-stack step-by-step?

I'm trying to debug this error:

01-12 13:38:18.068 275-275/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-12 13:38:18.068 275-275/? I/DEBUG: Build fingerprint: 'samsung/a53gxx/a53g:5.0.2/LRX22G/A500HXXU1BOJ2:user/release-keys'
01-12 13:38:18.068 275-275/? I/DEBUG: Revision: '10'
01-12 13:38:18.068 275-275/? I/DEBUG: ABI: 'arm'
01-12 13:38:18.068 275-275/? I/DEBUG: pid: 19854, tid: 19854, name: arif.mercuryapp  >>> com.hermessharif.mercuryapp <<<
01-12 13:38:18.068 275-275/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
01-12 13:38:18.098 275-275/? I/DEBUG:     r0 00000000  r1 00000000  r2 00000001  r3 b6ecbf44
01-12 13:38:18.098 275-275/? I/DEBUG:     r4 b879ebe0  r5 00000000  r6 be9e0c60  r7 00000000
01-12 13:38:18.098 275-275/? I/DEBUG:     r8 00000000  r9 b93ee710  sl 00000000  fp be9e0ce8
01-12 13:38:18.098 275-275/? I/DEBUG:     ip b51084dc  sp be9e0c10  lr b4effde7  pc b6e67204  cpsr 600f0030
01-12 13:38:18.098 275-275/? I/DEBUG: backtrace:
01-12 13:38:18.098 275-275/? I/DEBUG:     #00 pc 00090204  /system/lib/libandroid_runtime.so (GraphicsJNI::getNativeCanvas(_JNIEnv*, _jobject*)+11)
01-12 13:38:18.098 275-275/? I/DEBUG:     #01 pc 00091c31  /system/lib/libandroid_runtime.so
01-12 13:38:18.098 275-275/? I/DEBUG:     #02 pc 00277099  /system/framework/arm/boot.oat
01-12 13:38:19.468 275-275/? I/DEBUG: Tombstone written to: /data/tombstones/tombstone_04

I learned from this question that I should use ndk-stack to get the meaning of the error log.

So I downloaded the Android NDK using sdk manager in Android Studio and now have an ndk-bundle folder in my sdk directory.

I have saved above error log in error.txt and want to make sense of it. According to this documentation I think I should use the -dump option.

$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi-v7a -dump error.txt

The documentation says:

To use ndk-stack, you first need a directory containing unstripped versions of your app's shared libraries.

FYI, I have no idea what that might be.

If you use ndk-build, these unstripped shared libraries are found in $PROJECT_PATH/obj/local/, where is your device's ABI.

But I don't have the directory and I don't know how to make it.

I never have used ndk.

I tried this instruction but had no luck. Can't even make the make work. (ironic)

Can you please give me a step-by-step instruction? literally step-by-step.

TL;DR:

I have the above error log and need you to help me understand it.

I don't know anything about ndk and how you build with it.

Thank you for your patience. I know the question might be dumb.

like image 326
Mohsen Avatar asked Jan 12 '19 14:01

Mohsen


People also ask

What is the NDK and why is it useful?

The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.

What is the difference between NDK and sdk?

Android provides Native Development Kit (NDK) to support native development in C/C++, besides the Android Software Development Kit (Android SDK) which supports Java.


1 Answers

Unfortunately, this crash has nothing to do with NDK and you can learn nothing from ndk-stack in this case.

Let me explain. ndk-stack is a tool to decipher as crash log in your own native code. Here, you don't have native code to debug. This app crashed in a system library, and there is no way you can get the debug info (the unstripped version of these system libraries) for this specific device.

If you know how to reproduce this crash on Android emulator, you have some chance to debug this native crash further. But most likely, it's a bug that is not related to the native code. Maybe, you tried to draw to canvas after it was discarded.

like image 157
Alex Cohn Avatar answered Sep 19 '22 21:09

Alex Cohn