简体   繁体   English

使用带有Firebase身份验证的ProGuard,Flutter构建崩溃

[英]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: 我按照这些说明将ProGuard添加到Flutter ,现在我在启动应用程序时看到了这个异常:

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

This is obviously connected to Firebase Auth . 这显然与Firebase Auth相关联 The mentioned instructions also state the following: 上述说明还说明如下:

Any additional libraries (for example, Firebase) require their own rules to be added. 任何其他库(例如,Firebase)都需要添加自己的规则。

I did, however, not find any resources which show what statements I would need to append to proguard-rules.pro . 但是,我没有找到任何资源来显示我需要附加到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. 我可以想象其他Firebase组件在Auth组件修复后会发生类似的崩溃,所以我想知道“例如Firebase”的含义是什么,即是否有每个组件的规则或者我是否只需要解决这个问题用于Firebase身份验证。

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. Proguard为您提供了几个功能:删除死代码,通过将类成员和包名称重命名为短字符串来减少代码大小,并通过重命名,使代码更难以阅读,从而进行逆向工程。

By keeping the whole com.google.firebase tree intact you are not benefiting from the size reductions. 通过保持整个com.google.firebase树完好无损,您无法从减小尺寸中受益。 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. 你可以只用实验keep荷兰国际集团您使用(你可能无法告诉那些是什么,而不必读取火力插件实现),以达到降低大小顶层API类,但是这是一个大量的工作,实现了可能减少在APK大小,可能会引入一些脆弱性。

No, it is not 'optimal', but it's simple. 不,它不是“最佳”,但它很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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