Home » Android » android – Flutter build crashes using ProGuard with Firebase Auth

android – Flutter build crashes using ProGuard with Firebase Auth

Posted by: admin June 15, 2020 Leave a comment


I followed these instructions on adding ProGuard to Flutter and am now seeing this exception when starting the application:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/auth/internal/zzae;

This is obviously connected to Firebase Auth. The mentioned instructions also state the following:

Any additional libraries (for example, Firebase) require their own rules to be added.

I did, however, not find any resources which show what statements I would need to append to proguard-rules.pro.
I can imagine that other Firebase components would crash similarly after the Auth component is fixed, so I am wondering what the meaning of “for example, Firebase” is, i.e. if there are rules for every component or if I will just need to fix this for Firebase Authentication.

How to&Answers:


-keep class com.google.firebase.** { *; }

Proguard is providing you with several features: dead code removal, code size reduction by renaming class members and package names to short strings and, by that renaming, making the code more difficult to read and thus reverse engineer.

By keeping the whole com.google.firebase tree intact you are not benefiting from the size reductions. I guess obfuscation is irrelevant in this case since it’s a open source library.

You could experiment with just keeping the top level API classes that you use (you may not be able to tell what those are without reading the firebase plugin implementation) to achieve the size reduction, but that’s a lot of work to achieve a possible reduction in APK size, and probably introduces some fragility.

No, it is not ‘optimal’, but it’s simple.