问题现象
1, 依赖 flutterBugly ^0.4.4
2, debug包没问题
3, release启动 白屏/黑屏 一直卡住
4,去除bugly就正常
看android logcat 有日志
Caused by: java.lang.ClassNotFoundException: com.crazecoder.flutterbugly.FlutterBuglyPlugin
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(Unknown Source:6)
at java.lang.reflect.Method.invoke(Native Method)
at io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister.registerGeneratedPlugins(Unknown Source:21)
at io.flutter.embedding.android.FlutterActivity.configureFlutterEngine(Unknown Source:9)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(Unknown Source:58)
at io.flutter.embedding.android.FlutterActivity.onCreate(Unknown Source:13)
at android.app.Activity.performCreate(Activity.java:8241)
at android.app.Activity.performCreate(Activity.java:8207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3736)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3937)
以及
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method postCatchedException on channel crazecoder/flutter_bugly
问题分析
看到上面的结果,大概率就是混淆原因。
找到依赖包的proguard文件
###########bugly##############
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
-keep class com.crazecoder.flutterbugly.bean.** { *; }
有对bean保持,但没 keep FlutterBuglyPlugin
加下 -keep class com.crazecoder.flutterbugly.FlutterBuglyPlugin { *; } 试试看。
果然ok。
解决方案
1, 不直接依赖pub里的版本
2, 下载成本地依赖,https://pub.dev/packages/flutter_bugly/versions
3, 修改模块的proguard-rules.pro, 追加 -keep class com.crazecoder.flutterbugly.FlutterBuglyPlugin { *; }