flutter android 构建问题 flutter 更新后

问题描述 投票:0回答:1

构建和运行工作正常,但在发布版本中,我开始发现问题:

ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/chiragjuneja/Documents/work/playground/yashutales/badminton_score_tracker/build/flutter_inappwebview_android/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class android.window.BackEvent (referenced from: void io.flutter.embedding.android.FlutterActivity.startBackGesture(android.window.BackEvent) and 3 other contexts)
android flutter android-r8
1个回答
0
投票

缺失的类与 Android 相关,可能是由于 R8 缩减了基本代码。要解决这个问题:

导航到 Flutter 项目的 android 目录并打开 proguard-rules.pro 文件。 如果没有这个文件,请在 android/app 目录下创建一个

-keep class android.window.BackEvent { *; }
-keep class io.flutter.embedding.android.FlutterActivity { *; }

运行 flutter pub Upgrade 以更新所有 Flutter 依赖项。

确保您的 flutter_inappwebview 插件是最新的。您可以通过检查 flutter_inappwebview 的最新版本并更新 pubspec.yaml 来完成此操作

flutter clean
flutter pub get
flutter build apk --release
© www.soinside.com 2019 - 2024. All rights reserved.