To debug a native Android application, a binary called gdbserver and its associated gdb.setup must be included in the generated APK file. Including this into the APK can be very painful in Gradle, so here's a workaround I found:
- Build your stuff the way you normally would (I'm assuming you know already how to build a native app, and if you don't there are guides online that explain it much better than I could).
- Deploy your application the way you normally would.
- Discover ndk-gdb won't run. Bang forehead against keyboard a few times.
- After losing some hours looking at logs, figure out there's no gdbserver included in your apk.
- Lose some more hours trying to figure out how to include it in your apk using Gradle.
- Give up. Bang forehead against keyboard some more.
- find the gdbserver and gdb.setup in your build directory.
- adb push each of these files to the device.
- Using adb shell, move the files you copied to /data/app-lib/com.yourapp/ - you may need to root your device for this.
- Profit! ndk-gdb now works.
Edit: remember you may need to chmod +777 your gdbserver.
you just need to add "jniDebuggable true" to your debug buildType.
ReplyDeleteThis option is there for quite a long time.
Thanks for the info! I recall trying that option and it still didn't manage to include the gdbserver binary. Hopefully it does now.
ReplyDelete