You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter更新后Android Release构建报错:缺失android.window.BackEvent类

Flutter更新后Release构建R8缺失类错误的解决办法

Flutter更新完成后,Debug模式下构建和运行均正常,但执行Release构建时出现如下错误:

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)

解决方案

经过测试验证,以下步骤可解决该问题:

  • 新建proguard-rules.pro文件,添加ProGuard规则:
    -keep class android.window.BackEvent { *; }
    
  • 修改Gradle文件中的buildTypes配置,让Release构建加载上述规则文件:
    buildTypes {
            release { 
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
  • 降级com.android.application插件版本,从8.1.0调整为7.3.0:
    原配置:
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "8.1.0" apply false
        id "org.jetbrains.kotlin.android" version "1.8.22" apply false
    }
    
    修改后:
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "7.3.0" apply false
        id "org.jetbrains.kotlin.android" version "1.8.22" apply false
    }
    

内容的提问来源于stack exchange,提问作者learning-everyday

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 08:50:01