4ntoine
4ntoine

Reputation: 20422

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).

Upvotes: 34

Views: 29599

Answers (3)

inkflaw
inkflaw

Reputation: 67

In gradle 8.7, AGP 8.3.2, it should be

android {
    buildTypes {
        release {
            ...
        }
        debug {
            ...
            packaging {
                jniLibs {
                    keepDebugSymbols += "**/*.so"
                }
            }
        }
    }
}

Upvotes: 4

Wayne Cai
Wayne Cai

Reputation: 778

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

packagingOptions {
    doNotStrip "*/arm64-v8a/*.so"
    doNotStrip "*/armeabi-v7a/*.so"
    doNotStrip "*/x86/*.so"
    doNotStrip "*/x86_64/*.so"
}

Upvotes: 59

Dan Albert
Dan Albert

Reputation: 10509

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

Upvotes: 7

Related Questions