简体   繁体   中英

Flutter build crashes using ProGuard with Firebase Auth

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, ie if there are rules for every component or if I will just need to fix this for Firebase Authentication.

Include

-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 keep ing 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM