Firebase messging crashes the app only in release build

Issue

My application uses Firebase messaging and the application works fine in debug mode, but when I build it in the release mode it crashes upon receiving a message from Firebase. I’m assuming that the onMessage.listen somehow crashes the app. The devices where I tested it were Android devices. Is there anything that I could’ve missed during the Firebase setup within the app or are there any known fixes for this?

Edit – this is the error that I get:

E/AndroidRuntime(26859): FATAL EXCEPTION: firebase-iid-executor
E/AndroidRuntime(26859): Process: com.company.scrcapp, PID: 26859
E/AndroidRuntime(26859): java.lang.IllegalAccessError: Illegal class access: 'b.c.a.b.d.a' attempting to access 'b.c.a.b.b.a.c' (declaration of 'b.c.a.b.d.a' appears in base.apk)
E/AndroidRuntime(26859):        at b.c.a.b.d.a.<init>(Unknown Source:169)
E/AndroidRuntime(26859):        at b.c.a.b.d.a.<init>(:1)
E/AndroidRuntime(26859):        at com.google.firebase.messaging.l0.b(:1)
E/AndroidRuntime(26859):        at com.google.firebase.messaging.Y.e(:2)
E/AndroidRuntime(26859):        at com.google.firebase.messaging.m.call(:1)
E/AndroidRuntime(26859):        at b.c.a.b.e.F.run(Unknown Source:4)
E/AndroidRuntime(26859):        at com.google.firebase.messaging.n.execute(Unknown Source:0)
E/AndroidRuntime(26859):        at b.c.a.b.e.m.c(Unknown Source:20)
E/AndroidRuntime(26859):        at com.google.firebase.messaging.o.c(:1)
E/AndroidRuntime(26859):        at b.c.a.b.a.a.b(:1)
E/AndroidRuntime(26859):        at b.c.a.b.a.a.a(Unknown Source:21)
E/AndroidRuntime(26859):        at b.c.a.b.a.g.run(Unknown Source:10)
E/AndroidRuntime(26859):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(26859):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(26859):        at com.google.android.gms.common.util.e.b.run(Unknown Source:6)
E/AndroidRuntime(26859):        at java.lang.Thread.run(Thread.java:923)

Solution

The problem was solved by adding code below to /android/app/build.gradle:

...
buildTypes {
        release {
            ...
            shrinkResources false
            minifyEnabled false
        }
    }

and adding code below to /android/gradle.properties:

android.enableR8=false

Answered By – kforjan

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.