How to add debug symbols to build.gradle

Janaka picture Janaka · Aug 12, 2020 · Viewed 9.2k times · Source

I have created android build of my Flutter application.

Then I created an internal testing release. It is showing a 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.

Basically what I had to do is add following to build.gradle file according to the link they show.

android.buildTypes.release.ndk.debugSymbolLevel = { SYMBOL_TABLE | FULL }

I assume it is android/app/build.gradle they are talking about.

Not sure exactly where in that file I have to add this line.

Can someone point out where to add this line?

Answer

Adam picture Adam · Aug 16, 2020

To use the option ndk debugSymbolLevel as written in the docs you need an android gradle plugin 4.1 or later. At the time of writing the lastest 4.1 version is 4.1.0

You will need also to install ndk and cmake for android studio.

In your android build.gradle you need the to set android gradle plugin version 4.1.0:

buildscript {
    ...
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        ...
    }

Then in the android/app build.gradle add:

...
android {
    ...
    ndkVersion "21.3.6528147" # you see the ndk version in the android studio sdk-manager
    ...
    buildTypes {
        release {
            ...
            ndk {
                debugSymbolLevel 'SYMBOL_TABLE'
            }
        }   
    }
}

when you then run: flutter build appbundle it should finish after a while with an appbundle that is twice the size.