Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid stripping for native code symbols for android app

I'm getting sigsegv 11 in native code and i need to avoid stripping to understand what's wrong. The app uses library (aar) and i was able to avoid stripping for the aar with 'cmd-strip' hack. But in the apk stripped version of .so is used anyway so the app strips the symbols, probably while transformNative_libsWithStripDebugSymbolForDebug gradle task. Any change to avoid it?

PS. Found similar question on SO but it's a bit different (using aar here with not stripped symbols in my case).

like image 912
4ntoine Avatar asked Nov 01 '16 06:11

4ntoine


People also ask

How do you obfuscate codes on Android?

You can obfuscate Android code to provide security against reverse engineering. You can use the Android ProGuard tool to obfuscate, shrink, and optimize your code. Obfuscated code can be more difficult for other people to reverse engineer.

What are Android Debug symbols?

Debugging symbolsA debugging symbol file contains full debugging information and a symbol table. Use it to: Resolve stack traces and to debug applications that you have source code available for. Attach a native debugger to the application and debug the code.

What is minify in Android?

minify is an Android tool that will decrease the size of your application when you go to build it. It's extremely useful as it means smaller apk files! It detects any code or libraries that aren't being used and ignores them from your final apk.

What is R8 in Android?

Enable shrinking, obfuscation, and optimization 0 and higher, R8 is the default compiler that converts your project's Java bytecode into the DEX format that runs on the Android platform. However, when you create a new project using Android Studio, shrinking, obfuscation, and code optimization is not enabled by default.


2 Answers

There's an undocumented method 'doNotStrip' in packagingOptions, just add following lines in your build.gradle

packagingOptions{     doNotStrip "*/armeabi/*.so"     doNotStrip "*/armeabi-v7a/*.so"     doNotStrip "*/x86/*.so" } 
like image 180
Wayne Cai Avatar answered Sep 25 '22 21:09

Wayne Cai


Fortunately you don't actually need to keep the symbols in the app. The NDK ships a tool called ndk-stack (it's in the root of the NDK) that can symbolize a stack trace for you: https://developer.android.com/ndk/guides/ndk-stack.html

like image 30
Dan Albert Avatar answered Sep 25 '22 21:09

Dan Albert