build and run works fine but in release build, I started finding issue:
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)
Solved:
After some more googling and trying out various suggestions, this worked for me.
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
updating the gradle file with the above change post adding
-keep class android.window.BackEvent { *; }
in proguard-rules.pro that I created for this only.
And I changed plugin details
from
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
}
to
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
}
Hope it helps someone else too.
2
Answers
After some more googling and trying out various suggestions, this worked for me.
updating the gradle file with the above change post adding
in proguard-rules.pro that I created for this only.
And I changed plugin details from
to
Hope it helps someone else too.
The missing classes are related to Android and could be due to R8 shrinking essential code. To address this:
Navigate to your Flutter project’s android directory and open the proguard-rules.pro file.
If you don’t have this file, create one under android/app directory
Run flutter pub upgrade to update all Flutter dependencies.
Ensure your flutter_inappwebview plugin is up to date. You can do this by checking the latest version of flutter_inappwebview and updating your pubspec.yaml