我完成了应用程序的测试,但每当我运行 flutter build apk 或 flutter build apk --release 时,我都会遇到此错误
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in C:\Users\HP\Downloads\Friendnpal_flutter-main\Friendnpal_flutter-main\build\flutter_inappwebview\outputs\mapping\release\missing_rules.txt.
ERROR: R8: Missing class android.window.BackEvent (referenced from: void io.flutter.view.FlutterView.startBackGesture(android.window.BackEvent) and 1 other context)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_inappwebview:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 35s
Running Gradle task 'assembleRelease'... 36.7s
Gradle task assembleRelease failed with exit code 1
我尝试将我的missing.txt文件中的内容复制到我的proguard规则中,这是我的proguard规则
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn android.window.BackEvent
# https://github.com/flutter/flutter/issues/78625#issuecomment-804164524
#-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
#-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
将其添加到顶部的
android/build.gradle
文件中。
subprojects {
afterEvaluate {
if (it.name == "flutter_inappwebview_android") {
it.android.buildTypes.release.minifyEnabled = false
}
}
}
这对我有用。
如果这不适合您,您可以参考this了解更多