Flutter local notification causing crash, only in the APK version

I had the same problem and it was driving me nuts. It only happens on a release build and appears to be related to AndroidInitializationSettings('app_icon')

The flutter_local_notifications docs section on Android Integration says to add

-keep class com.dexterous.** { *; }

to /android/app/proguard-rules.pro


If you export release apk format so after installed crash the app. You have to make these steps:

  1. Added proguard-files.pro file Than you have to added bottom of the file this code
## flutter_local_notification plugin rules
-keep class com.dexterous.** { *; }

  1. Your build.gradle file have to be
buildTypes {

    release {
        signingConfig signingConfigs.release
        // Enables code shrinking, obfuscation, and optimization for only
        // your project's release build type.
        minifyEnabled false

        // Enables resource shrinking, which is performed by the
        // Android Gradle plugin.
        shrinkResources false

        // Includes the default ProGuard rules files that are packaged with
        // the Android Gradle plugin. To learn more, go to the section about
        // R8 configuration files.
        proguardFiles getDefaultProguardFile(
                'proguard-android-optimize.txt'),
                'proguard-rules.pro'
    }
}


I have faced the same problem. I added the following line to the proguard-rules.pro -keep class com.dexterous.** { *; } but nothing worked. Problem was that proguard-rules.pro file was located in the local notifications plugin library.

So I created a copy of this file in android/app directory and finally it works. I have spent almost 2 days on this issue.

Do not forget to add the following code in res/raw/keep.xml file to keep your icon resource for your notification file as shown here

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@drawable/*,@raw/slow_spring_board" />