flutter_inappwebview
flutter_inappwebview copied to clipboard
Build error with latest flutter/agp versions
- [x] I have read the Getting Started section
- [x] I have already searched for the same problem
Environment
| Technology | Version |
|---|---|
| Flutter version | 3.22 |
| Plugin version | 1.0.13 |
| Android version | 14 |
| iOS version | -- |
| macOS version | -- |
| Xcode version | -- |
| Google Chrome version | -- |
| Android Gradle Plugin | 8.4.0 |
Device information: irrelevant, as this is a build error
Description
Expected behavior:
Be able to compile an app on Android using this plugin with obfuscation/minification
Current behavior:
Build error during minification:
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in .../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)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_inappwebview_android:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete
Steps to reproduce
- Depend on flutter_inappwebview
- Upgrade to latest flutter/AGP/...
- Do a release build with minification (e.g.
flutter build apk --obfuscate --split-debug-info /tmp/debug-info. Alternatively, skip--obfuscate --split-debug-info ...and setminifyEnabled trueinandroid/app/build.gradle
👋 @holzgeist
NOTE: This comment is auto-generated.
Are you sure you have already searched for the same problem?
Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!
If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.
In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.
Following these steps can save you, me, and other people a lot of time, thanks!
It would be great if the according PR could be merged quickly, as this currently blocks us (and probably other devs as well) from building releases, and downgrading to an earlier version is quite cumbersome as the API has changed in between.
It would be great if the according PR could be merged quickly, as this currently blocks us (and probably other devs as well) from building releases, and downgrading to an earlier version is quite cumbersome as the API has changed in between.
Any luck pointing your dependency to the pull request? it doesn't work on my side
Ah, good point! Got it to run with:
dependency_overrides:
# TODO: Recheck once flutter_inappwebview version >6.0.0 is released
flutter_inappwebview_android:
git:
url: https://github.com/holzgeist/flutter_inappwebview
path: flutter_inappwebview_android
ref: d89b1d32638b49dfc58c4b7c84153be0c269d057
I closed the according PR because it was a duplicate of #2102
Ah, good point! Got it to run with:
dependency_overrides: # TODO: Recheck once flutter_inappwebview version >6.0.0 is released flutter_inappwebview_android: git: url: https://github.com/holzgeist/flutter_inappwebview path: flutter_inappwebview_android ref: d89b1d32638b49dfc58c4b7c84153be0c269d057
You saved my deploy today. Thank you so much!
Still having an issue even afetr depending on holzgeist repo
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/username/Desktop/projectname/build/app/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class com.google.j2objc.annotations.ReflectionSupport$Level (referenced from: com.google.common.util.concurrent.AbstractFuture)
Missing class com.google.j2objc.annotations.ReflectionSupport (referenced from: com.google.common.util.concurrent.AbstractFuture)
Missing class com.google.j2objc.annotations.RetainedWith (referenced from: com.google.common.collect.ImmutableSet com.google.common.collect.ImmutableMap.entrySet and 3 other contexts)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete
Still having an issue even afetr depending on
holzgeistrepoERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/username/Desktop/projectname/build/app/outputs/mapping/release/missing_rules.txt. ERROR: R8: Missing class com.google.j2objc.annotations.ReflectionSupport$Level (referenced from: com.google.common.util.concurrent.AbstractFuture) Missing class com.google.j2objc.annotations.ReflectionSupport (referenced from: com.google.common.util.concurrent.AbstractFuture) Missing class com.google.j2objc.annotations.RetainedWith (referenced from: com.google.common.collect.ImmutableSet com.google.common.collect.ImmutableMap.entrySet and 3 other contexts) FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:minifyReleaseWithR8'. > A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable > Compilation failed to complete
@specOper99 - looks like your issue is not linked to flutter_inappwebview, but that fact that your proguard.pro file is not there.
check if you have the proguard-rules.pro file in your project (android/app/). if not create one and then add the following lines
-ignorewarnings -keep class * { public private *; }
@Yohan-J You have an issue with Proguard but it's a different one. check the actual issue here.
- Actual issue is about the
R8: Missing class android.window.BackEventand your issue isR8: Missing class com.google.j2objc.annotations.ReflectionSupport$Levelthat is from a different thing.
@nayanbabariya yes, this wasn't my issue, but i was also replying to the comment above mine, stating that his issue was something else.
@Yohan-J Okay. but the mentioned issue is from the flutter_inappwebview plugin.
@Yohan-J Thank you for your answer.
Actually I noticed that lately (before few hours) that the problem is not related to flutter_inappwebview but it is related to awesome_notification
if somebody is having it then can try to downgrade in order to be able to build cause whenever I try to ignore the warns it never changes its behaviour.
In my case, it seems the issue was caused by youtube_player_flutter that depends on flutter_inappwebview
https://github.com/holzgeist/flutter_inappwebview
For Flutter project this is :
flutter_inappwebview: git: url: https://github.com/holzgeist/flutter_inappwebview.git path: flutter_inappwebview ref: fix-proguard-rules
In Flutter still get an error :
Error: Type 'PlatformWebViewEnvironmentCreationParams' not found. required PlatformWebViewEnvironmentCreationParams params,
It seems that this upgraded package version with
'-dontwarn android.window.BackEvent'
added to Proguard causes following unexpected behaviour when running 'pub get' : Folder 'webview_environment' is removed from package
'https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_platform_interface/lib/src'
. This causes missing classes when running Flutter project
This fix of https://github.com/MobileEasternts/flutter_inappwebview/tree/master is more complete and the branch master has the correction done which solves this issue
flutter_inappwebview: git: url: https://github.com/MobileEasternts/flutter_inappwebview.git path: flutter_inappwebview
the same here
the same here. but, I solved it.
my error code
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/jeonglockpark/Desktop/work/daopass/daopass/build/flutter_inappwebview_android/outputs/mapping/release/missing_rules.txt.
Add 1
dependency_overrides:
# TODO: Recheck once flutter_inappwebview version >6.0.0 is released
flutter_inappwebview_android:
git:
url: https://github.com/holzgeist/flutter_inappwebview
path: flutter_inappwebview_android
ref: d89b1d32638b49dfc58c4b7c84153be0c269d057
Add 2
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn com.google.j2objc.annotations.ReflectionSupport$Level
-dontwarn com.google.j2objc.annotations.ReflectionSupport
-dontwarn com.google.j2objc.annotations.RetainedWith
The build was successful with the two additional methods above. Hopefully the package will be updated normally soon.
Thanks a lot.
the same here. but, I solved it.
my error code
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/jeonglockpark/Desktop/work/daopass/daopass/build/flutter_inappwebview_android/outputs/mapping/release/missing_rules.txt.Add 1
dependency_overrides: # TODO: Recheck once flutter_inappwebview version >6.0.0 is released flutter_inappwebview_android: git: url: https://github.com/holzgeist/flutter_inappwebview path: flutter_inappwebview_android ref: d89b1d32638b49dfc58c4b7c84153be0c269d057Add 2
# Please add these rules to your existing keep rules in order to suppress warnings. # This is generated automatically by the Android Gradle plugin. -dontwarn com.google.j2objc.annotations.ReflectionSupport$Level -dontwarn com.google.j2objc.annotations.ReflectionSupport -dontwarn com.google.j2objc.annotations.RetainedWithThe build was successful with the two additional methods above. Hopefully the package will be updated normally soon.
Thanks a lot.
Sorry, where am i putting this add, which file, Gradle or proguard?
the same here. but, I solved it. my error code
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/jeonglockpark/Desktop/work/daopass/daopass/build/flutter_inappwebview_android/outputs/mapping/release/missing_rules.txt.Add 1
dependency_overrides: # TODO: Recheck once flutter_inappwebview version >6.0.0 is released flutter_inappwebview_android: git: url: https://github.com/holzgeist/flutter_inappwebview path: flutter_inappwebview_android ref: d89b1d32638b49dfc58c4b7c84153be0c269d057Add 2
# Please add these rules to your existing keep rules in order to suppress warnings. # This is generated automatically by the Android Gradle plugin. -dontwarn com.google.j2objc.annotations.ReflectionSupport$Level -dontwarn com.google.j2objc.annotations.ReflectionSupport -dontwarn com.google.j2objc.annotations.RetainedWithThe build was successful with the two additional methods above. Hopefully the package will be updated normally soon. Thanks a lot.
Sorry, where am i putting this add, which file, Gradle or proguard?
The first add goes to your pubspec.yaml file.
Just add that below your dependencies block if you don't have any dependency_overrides yet. This tells the build pipeline to not use the real dependency but instead the one defined as override (a specific commit in a different repo).
The second one is not required in my setup, so you might not need it either. But if you do, this goes to the proguard-rules.pro file in your project's android/app folder.
Noted with thanks, let me do that and build.
On Wed, Jul 3, 2024, 15:59 Sergio Molchanovsky @.***> wrote:
Ah, good point! Got it to run with:
dependency_overrides:
TODO: Recheck once flutter_inappwebview version >6.0.0 is released
flutter_inappwebview_android: git: url: https://github.com/holzgeist/flutter_inappwebview path: flutter_inappwebview_android ref: d89b1d32638b49dfc58c4b7c84153be0c269d057
After I added dependency_overrides, my apk size increased from 60 Mb to almost 110 Mb! Seems like you turned off some Proguard rules, and some unneeded stuff got into the assembly.
— Reply to this email directly, view it on GitHub https://github.com/pichillilorenzo/flutter_inappwebview/issues/2139#issuecomment-2206165151, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMS3LJIU4U3FGOGHOXJFWS3ZKP7TBAVCNFSM6AAAAABHV2CYFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBWGE3DKMJVGE . You are receiving this because you commented.Message ID: @.***>
I'm still sitting on a flutter_inappwebview 5.8, and we managed to remove this R8 error by adding the following line in the beginning of the android/build.gradle script:
project.gradle.startParameter.excludedTaskNames.add(":flutter_inappwebview:minifyReleaseWithR8")
I hope it will help to someone.
I'm still sitting on a flutter_inappwebview 5.8, and we managed to remove this R8 error by adding the following line in the beginning of the
android/build.gradlescript:project.gradle.startParameter.excludedTaskNames.add(":flutter_inappwebview:minifyReleaseWithR8")I hope it will help to someone.
This really helps
We tried @subzero911 's fix (which seems better than referencing a PR branch) but did not work for our app, because when building from clean repo, skipping the minification task caused other tasks to fail because they weren't finding the expected output (the jar file).
This is an evolution of that fix, which properly disables minification instead of skipping the task, and for us it works even when building from scratch.
Add this in the android/build.gradle file:
subprojects {
afterEvaluate {
if (it.name == "flutter_inappwebview_android") {
it.android.buildTypes.release.minifyEnabled = false
}
}
}
If your file already has a subprojects / afterEvaluate section you might have to put it in there instead.
Anyway, should the minification be enabled for an open source android library project? I think that generally it shoudn't, because the code would be merged with the whole app's codebase and minification would then run globally.. so a better "official" fix could be to change minifyEnabled to false in this project's build.gradle. @pichillilorenzo what do you think?
I still have this problem and none of solutions provided is working for me.
I encountered evaluation timing issues when configure within the android/build.gradle file. To resolve this, I moved the configuration to the settings.gradle file and used the beforeProject and afterEvaluate hooks. This method worked
include ":app", ":flutter_inappwebview_android"
gradle.beforeProject { project ->
if (project.name == "flutter_inappwebview_android") {
project.afterEvaluate {
if (project.hasProperty("android")) {
project.android.buildTypes.release.minifyEnabled = false
}
}
}
}
I'm still on version 5.8.0 because of some reasons, tried both methods above from @cc-rock and @HelmiAshraf and none of them worked :(
I can see the minifyEnabled property being set to false, if I println project.android.buildTypes.release.minifyEnabledit shows minifyEnabled as false but the same R8 error keep happening :(
I also added -dontwarn android.window.** to my proguard file and it also did not work :(
Did anyone manage to build in release mode with the version 5.8? Actually, did upgrading to 6.0.0 fixes the issue or not?
I encountered evaluation timing issues when configure within the
android/build.gradlefile. To resolve this, I moved the configuration to thesettings.gradlefile and used thebeforeProjectandafterEvaluatehooks. This method workedinclude ":app", ":flutter_inappwebview_android" gradle.beforeProject { project -> if (project.name == "flutter_inappwebview_android") { project.afterEvaluate { if (project.hasProperty("android")) { project.android.buildTypes.release.minifyEnabled = false } } } }
After I upgrade to Gradle 8.5, this solution works.
I'm still on version 5.8.0 because of some reasons, tried both methods above from @cc-rock and @HelmiAshraf and none of them worked :(
I can see the
minifyEnabledproperty being set to false, if I printlnproject.android.buildTypes.release.minifyEnabledit shows minifyEnabled as false but the same R8 error keep happening :(I also added
-dontwarn android.window.**to my proguard file and it also did not work :(Did anyone manage to build in release mode with the version 5.8? Actually, did upgrading to 6.0.0 fixes the issue or not?
@edisonlsm I'm using 5.8.0 and I made it work with @HelmiAshraf solution but you need to change "flutter_inappwebview_android" to "flutter_inappwebview" on version "5.x.x"
We tried @subzero911 's fix (which seems better than referencing a PR branch) but did not work for our app, because when building from clean repo, skipping the minification task caused other tasks to fail because they weren't finding the expected output (the jar file).
This is an evolution of that fix, which properly disables minification instead of skipping the task, and for us it works even when building from scratch. Add this in the
android/build.gradlefile:subprojects { afterEvaluate { if (it.name == "flutter_inappwebview_android") { it.android.buildTypes.release.minifyEnabled = false } } }If your file already has a subprojects / afterEvaluate section you might have to put it in there instead.
Anyway, should the minification be enabled for an open source android library project? I think that generally it shoudn't, because the code would be merged with the whole app's codebase and minification would then run globally.. so a better "official" fix could be to change
minifyEnabledto false in this project'sbuild.gradle. @pichillilorenzo what do you think?
Since the branch is no longer available (at least I can't connect to the branch anymore when run pub get), this solution works by far.
My build.gradle is this right now:
allprojects {
repositories {
google()
mavenCentral()
}
// --------------------- ADDED HERE ---------------------
subprojects {
afterEvaluate {
if (it.name == "flutter_inappwebview_android") {
it.android.buildTypes.release.minifyEnabled = false
}
}
}
}
// AND THIS IS THE REST OF MY GRADLE...
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Another problem, if it is a "problem", the package youtube_player_flutter: ^9.0.0 depends on flutter_inappwebview: ^6.0.0, and I cannot downgrade to inappwebview 5.8.0
Hope this package get and update soon! (8 months since last time to this days)
Thanks bro for the update
On Wed, Sep 11, 2024, 15:42 Juan Manuel Flecha @.***> wrote:
We tried @subzero911 https://github.com/subzero911 's fix (which seems better than referencing a PR branch) but did not work for our app, because when building from clean repo, skipping the minification task caused other tasks to fail because they weren't finding the expected output (the jar file).
This is an evolution of that fix, which properly disables minification instead of skipping the task, and for us it works even when building from scratch. Add this in the android/build.gradle file:
subprojects { afterEvaluate { if (it.name == "flutter_inappwebview_android") { it.android.buildTypes.release.minifyEnabled = false } } }
If your file already has a subprojects / afterEvaluate section you might have to put it in there instead.
Anyway, should the minification be enabled for an open source android library project? I think that generally it shoudn't, because the code would be merged with the whole app's codebase and minification would then run globally.. so a better "official" fix could be to change minifyEnabled to false in this project's build.gradle. @pichillilorenzo https://github.com/pichillilorenzo what do you think?
Since the branch is no longer available (at least I can't connect to the branch anymore when run pub get), this solution works by far.
My build.gradle is this right now:
allprojects { repositories { google() mavenCentral() } // --------------------- ADDED HERE --------------------- subprojects { afterEvaluate { if (it.name == "flutter_inappwebview_android") { it.android.buildTypes.release.minifyEnabled = false } } } }
// AND THIS IS THE REST OF MY GRADLE...
rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }
tasks.register("clean", Delete) { delete rootProject.buildDir }
Another problem, if it is a "problem", the package youtube_player_flutter: ^9.0.0 depends on flutter_inappwebview: ^6.0.0, and I cannot downgrade to inappwebview 5.8.0
Hope this package get and update soon! (8 months since last time to this days)
— Reply to this email directly, view it on GitHub https://github.com/pichillilorenzo/flutter_inappwebview/issues/2139#issuecomment-2343712786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMS3LJJY5VH33W4PZ3ANCNTZWBCERAVCNFSM6AAAAABHV2CYFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTG4YTENZYGY . You are receiving this because you commented.Message ID: @.***>
Is there any other package because it is still not working, same warning?