How to include debug symbols for a pre-built native library inside an Android App Bundle?


Background info

When uploading an app to the play store that uses a native library its necessary to also upload the native debug symbols to get useful crash/ANR info.

If you upload without symbols you receive the following warning: "This App Bundle contains native code, and you’ve not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug."

In the past when uploading apps as .apk files it was necessary to manually upload such debug info. Now using .aab if the native library is built via android studio its possible to set android.defaultConfig.ndk.debugSymbolLevel = 'FULL' at which point when you build a the .aab it will include the debug info automatically, you upload this single file and everything is done/working.

pre-built libraries

However its not always possible/ideal/necessary to build a library inside android studio. Sometimes there are reasons for libraries to be externally pre-built and just used by android studio not built by it; Android studio supports this via a directory structure which is described here
In short you just copy the libraries into the correct src/main/jniLibs/{ABI} path(s) and it is picked up and made part of the bundle.


  • Android studio can build a .aab that contains debug info that play store can understand so that you don’t need to upload it manually.
  • Android studio can use pre built native libraries if you place them in the right path structure
  • I am unable to find any documentation or way to do both of these things together, use native pre-built libraries but include their debug info in the .aab. Even though logically it should be possible to do this.

I have searched everywhere I think but can’t find anyone even talking about this really, how/where do you place the corresponding debug information so that that also can be included as part of the .aab? Is there a separate path for this, do they just need a specific file extension, does gradle need to be told what to do with them somehow?
Is it really just not possible?

Things I have tried:

  • Don’t split the debug info just leave them in the .so files – play store does not strip them then so you deliver giant debug versions of your builds to your users
  • Split the debug info into files with .so.dbg extension and place them alongside the .so files – they aren’t included in the .aab
  • Following the instructions (here and elsewhere) to manually zip and upload the symbols after uploading the .aab – this appears to work but isn’t the same convenience wise as having them in the .aab
  • I’ve tried building a sample app with android studio building a lib instead of using a pre-built lib just to verify that it does then include the debug info and what file extension it uses. Contents of a sample ..ab


After some more digging I found the task responsible for this is "ExtractNativeDebugMetadataTask" with which some effort can likely be tailored/altered to do custom things here.

However this ended up being unnecessary as while digging into this I discovered that it actually already works.
At least as of now in latest gradle versions (not sure about the past).
It was only failing due to some NDK path confusion which doesn’t fail the build/creation of the bundle building but just logs an easy to miss informational message.

Ultimately all you need to do to make this work is:

  1. Build your external .so files with -g -g3 or similar
  2. Do not strip them in any way
  3. Place them in jniLibs directory structure un-stripped
  4. Configure your build.gradle appropriately android{ ndk { debugSymbolLevel 'FULL' } ndkPath "$projectDir/path/to/NDK" }

Resulting .aab will contain the stripped .so files and the split-debug .so.dbg files all in the right location.

Answered By – Malcolm MacLeod

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published