我正在开发一个 Flutter 项目,该项目使用 Mesibo SDK 来实现聊天功能。当尝试构建 APK 时,我遇到以下错误:
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in .
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.
我查看了中生成的missing_rules.txt文件 缺少的类是 android.window.BackEvent。
如何解决缺少的 android.window.BackEvent 类? 我是否需要添加特定的保留规则以防止 R8 剥离必要的类? Flutter SDK、Android SDK 版本和 Mesibo SDK 之间是否存在兼容性问题需要解决?
首先,进入 Android 文件夹,然后在应用程序目录中,找到
build.gradle
文件。
在
android {}
块内,设置以下内容:
buildTypes {
release {
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
尝试这个配置。如果不起作用,请将以下两个属性设置为 false:
minifyEnabled true
shrinkResources true