pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.31k stars 1.64k forks source link

Build failed on Android Target SDK 33 #1223

Closed Dararii closed 2 years ago

Dararii commented 2 years ago

Environment

Technology Version
Flutter version 3.0.2
Plugin version 5.4.3+7
Android version API 33
iOS version Not Tested on iOS
Xcode version -

Device information:

Description

Break when target build version changed to 33 (Tiramisu on Android) Expected behavior: Build Complete Current behavior: Build Failed

Steps to reproduce

Nothing special to do. My project was able to build on targetSDK 32, but failed on targetSDK 33.

  1. Create a simple project, set target SDK and compile SDK version to 33 in Android setting.
  2. Depend on this library.

Images

Stacktrace/Logcat

Launching lib/main.dart on sdk gphone64 arm64 in debug mode... /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:280: error: cannot find symbol settings.setAppCachePath(options.appCachePath); ^ symbol: method setAppCachePath(String)

location: variable settings of type WebSettings /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:494: error: cannot find symbol settings.setAppCacheEnabled(false); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:504: error: cannot find symbol settings.setAppCacheEnabled(true); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:515: error: cannot find symbol settings.setAppCachePath(ctx.getCacheDir().getAbsolutePath()); ^ symbol: method setAppCachePath(String) location: variable settings of type WebSettings /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:517: error: cannot find symbol settings.setAppCacheEnabled(true); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:521: error: cannot find symbol settings.setAppCacheEnabled(false); ^ symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings /Users/dararii/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_webview/InAppWebView.java:767: error: cannot find symbol settings.setAppCachePath(newOptions.appCachePath); ^ symbol: method setAppCachePath(String) location: variable settings of type WebSettings

Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 7 errors FAILURE: Build failed with an exception.

BUILD FAILED in 27s Exception: Gradle task assembleDebug failed with exit code 1 Exited

github-actions[bot] commented 2 years ago

👋 @Dararii

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!

topex-psy commented 2 years ago

Need to downgrade targetSdkVersion and compileSdkVersion to 32 Also some other packages to older version, e.g: permission_handler: ^9.2.0

At least we can run our app until this issue fixed.

cvphat commented 2 years ago

same issue

nastaran-mohammadi commented 2 years ago

same issue

MTM-A commented 2 years ago

i also have the same problem

leopi99 commented 2 years ago

same here with Flutter 3.0.3

vytautas-pranskunas- commented 2 years ago

any fix?

muktadirsonyy911 commented 2 years ago

Same issue in flutter 3.0.3 and Dart 2.17.5

ghost commented 2 years ago

the solution can be downgrading the API level to 32. It worked for me

apparatchiki commented 2 years ago

Sadly I have other dependencies that require me to compile for / target API level 33... hope this can be sorted out soon.

bzamanbd commented 2 years ago

According to my project: 1) CompileSdkVersion to 32 2) Packages: permission_handler: ^9.2.0

Now I am able to open my App....

linpengteng commented 2 years ago

Sadly I have other dependencies that require me to compile for / target API level 33... hope this can be sorted out soon.

I encountered the same problem, but after I upgraded Android studio (2021.2.1 patch 1) and gradle (7.3.3), I can set targetsdkversion 33 and compilesdkversion 33, and flutter build apk successful.

venky9885 commented 2 years ago

Please solve this issue I am too facing it

nguyenhuuduc458 commented 2 years ago

Same here in android native with targetsdkversion 33 and compilesdkversion 33. Anyone who fixed this issue please reply to me soon. I really appreciate any help you can provide.

settings.setAppCacheEnabled(true);
            ^

symbol: method setAppCacheEnabled(boolean) location: variable settings of type WebSettings

venky9885 commented 2 years ago

For android getting same issue @pichillilorenzo please solve it ASAP we cant able to build app bundle

rukshanuddin commented 2 years ago

https://developer.android.com/sdk/api_diff/33/changes

Removed Methods

void setAppCacheEnabled(boolean) |   void setAppCacheMaxSize(long) |   void setAppCachePath(String)

Not sure what the resolution will be

rshrc commented 2 years ago

Need to downgrade targetSdkVersion and compileSdkVersion to 32 Also some other packages to older version, e.g: permission_handler: ^9.2.0

At least we can run our app until this issue fixed.

Getting this issue when using this plugin html_editor_enhanced which uses flutter_inappwebview.

Wont be able to downgrade to 32, already at flutter 3.0.5. Works flawlessly in Web, real pain is in compiling for Android

rshrc commented 2 years ago

Hi Guys! So I did a temp fix for people who still have an issue with this Android 33 SDK version.

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master

Add this to your pubspec.yaml. The temp fix we ran through our production web app, didn't seem to cause any crashes or problems. Helped compile the apps properly in Android SDK 33 with flutter 3.0.5. Hope this helps for a while!

manuwehmeier commented 2 years ago

I am also getting the same errors with version 5.4.3+7 of flutter_inappwebview. Since it is not possible for me to downgrade to API version 32 and we don't want to include a fork of this project into ours, it would be nice if this issue could be solved soon.

srihari9n commented 2 years ago

@pichillilorenzo @rshrc's fork seems to be working fine, can you please look into the changes and maybe a PR can be made and accepted? It is a pain to include forks as dependencies and then switch back to the original at later point keeping an eye on updates.

huylethanh commented 2 years ago

I got the same issue. please fix it.

vijayvaghela72 commented 2 years ago

Hi Guys! So I did a temp fix for people who still have an issue with this Android 33 SDK version.

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master

Add this to your pubspec.yaml. The temp fix we ran through our production web app, didn't seem to cause any crashes or problems. Helped compile the apps properly in Android SDK 33 with flutter 3.0.5. Hope this helps for a while!

PS D:\Code\customer main branch\Multivendor-Startt-From-2.0.4-> flutter pub get Because youtube_player_flutter 8.1.0 depends on flutter_inappwebview ^5.4.3+7 and no versions of youtube_player_flutter match >8.1.0 <9.0.0, youtube_player_flutter ^8.1.0 requires flutter_inappwebview from hosted. So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed. Running "flutter pub get" in Multivendor-Startt-From-2.0.4-...
pub get failed (1; So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed.)

facing this issue when add this dependency in pubspect.ymal file

rshrc commented 2 years ago

Hi Guys! So I did a temp fix for people who still have an issue with this Android 33 SDK version.

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master

Add this to your pubspec.yaml. The temp fix we ran through our production web app, didn't seem to cause any crashes or problems. Helped compile the apps properly in Android SDK 33 with flutter 3.0.5. Hope this helps for a while!

PS D:\Code\customer main branch\Multivendor-Startt-From-2.0.4-> flutter pub get Because youtube_player_flutter 8.1.0 depends on flutter_inappwebview ^5.4.3+7 and no versions of youtube_player_flutter match >8.1.0 <9.0.0, youtube_player_flutter ^8.1.0 requires flutter_inappwebview from hosted. So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed. Running "flutter pub get" in Multivendor-Startt-From-2.0.4-... pub get failed (1; So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed.)

facing this issue when add this dependency in pubspect.ymal file

Seems like you used the git repo in the dependency: key, need to use it in dependency_overrides.Share your pubspec.yaml once.

mehaknexever commented 2 years ago

Any new solution for this problem? I have tried above methods I cannot downgrade sdk version from 33 because system is specifying compilesdk version to be 33 and @rshrc solution gave me a lot of another errors.

vijayvaghela72 commented 2 years ago

Hi Guys! So I did a temp fix for people who still have an issue with this Android 33 SDK version.

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master

Add this to your pubspec.yaml. The temp fix we ran through our production web app, didn't seem to cause any crashes or problems. Helped compile the apps properly in Android SDK 33 with flutter 3.0.5. Hope this helps for a while!

PS D:\Code\customer main branch\Multivendor-Startt-From-2.0.4-> flutter pub get Because youtube_player_flutter 8.1.0 depends on flutter_inappwebview ^5.4.3+7 and no versions of youtube_player_flutter match >8.1.0 <9.0.0, youtube_player_flutter ^8.1.0 requires flutter_inappwebview from hosted. So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed. Running "flutter pub get" in Multivendor-Startt-From-2.0.4-... pub get failed (1; So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed.) facing this issue when add this dependency in pubspect.ymal file

Seems like you used the git repo in the dependency: key, need to use it in dependency_overrides.Share your pubspec.yaml once.

name: eshop_multivendor description: eShop Multivendor App

publish_to: 'none'

version: 1.0.0+4

environment: sdk: ">=2.15.1 <3.0.0"

dependencies: flutter: sdk: flutter

cupertino_icons: ^1.0.4 http: ^0.13.4 shared_preferences: ^2.0.15 connectivity: ^3.0.6 jaguar_jwt: ^3.0.0 flutter_local_notifications: ^9.5.3+1 path_provider: ^2.0.10 firebase_messaging: ^11.4.1 flutter_rating_bar: ^4.0.1 photo_view: ^0.14.0 firebase_auth: ^3.3.19 sms_autofill: ^2.2.0 intl: ^0.17.0 country_code_picker: ^2.0.2 google_maps_flutter: ^2.1.6 geolocator: ^8.2.1 file_picker: ^4.6.1 shimmer: ^2.0.0 geocoding: ^2.0.2 razorpay_flutter: ^1.2.9 flutter_paystack: git: url: https://github.com/definitelyme/flutter_paystack.git ref: a4a33c3dd0a12f46d655a2e63d11e9f20ba82d01 flutter_html_to_pdf: ^0.7.0 permission_handler: ^9.2.0 in_app_review: ^2.0.4 firebase_dynamic_links: ^4.2.5 open_file: ^3.2.1 provider: ^6.0.3 share_plus: ^4.0.5 video_player: ^2.4.2 flutter_svg: ^0.23.0+1 paytm: ^3.0.1 youtube_player_flutter: ^8.1.0 package_info: ^2.0.2 url_launcher: ^6.1.2 sqflite: ^2.0.2 version: ^2.0.0 flutter_downloader: ^1.8.0+1 speech_to_text: ^5.5.0 tuple: ^2.0.0 cached_network_image: ^3.2.1 lottie: ^1.2.1 flutter_stripe: ^3.0.2 flutter_widget_from_html: ^0.8.5
flutter_html: ^2.2.1 google_sign_in: ^5.3.3

dev_dependencies: flutter_test: sdk: flutter flutter_localizations: sdk: flutter flutter_lints: ^2.0.1

flutter:

uses-material-design: true

assets:

vijayvaghela72 commented 2 years ago

Hi Guys! So I did a temp fix for people who still have an issue with this Android 33 SDK version.

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master

Add this to your pubspec.yaml. The temp fix we ran through our production web app, didn't seem to cause any crashes or problems. Helped compile the apps properly in Android SDK 33 with flutter 3.0.5. Hope this helps for a while!

PS D:\Code\customer main branch\Multivendor-Startt-From-2.0.4-> flutter pub get Because youtube_player_flutter 8.1.0 depends on flutter_inappwebview ^5.4.3+7 and no versions of youtube_player_flutter match >8.1.0 <9.0.0, youtube_player_flutter ^8.1.0 requires flutter_inappwebview from hosted. So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed. Running "flutter pub get" in Multivendor-Startt-From-2.0.4-... pub get failed (1; So, because eshop_multivendor depends on both youtube_player_flutter ^8.1.0 and flutter_inappwebview from git, version solving failed.) facing this issue when add this dependency in pubspect.ymal file

Seems like you used the git repo in the dependency: key, need to use it in dependency_overrides.Share your pubspec.yaml once.

i am not using this package any more but still getting this error , how can i resolve any solution ?

even i try above solution ,

also done flutter clean , pub , etc. but no luck there ,

rshrc commented 2 years ago

delete pubspec.lock file and run flutter pub get again

or

run flutter pub cache repair

vijayvaghela72 commented 2 years ago

delete pubspec.lock file and run flutter pub get again

or

run flutter pub cache repair yes i have done same ,

deleted pubspec.lock folder and also flutter pub cache repair , but there is no luck . still when i run pub get in pubspec.lock file it's show flutter_inappwebview: dependency: transitive description: name: flutter_inappwebview url: "https://pub.dartlang.org" source: hosted version: "5.4.3+7"

but i have not use this package in pubspect.ymal file ,

please help me if have any other solution because i am stucked here

vijayvaghela72 commented 2 years ago

even for this issue i have done flutter setup again , but still no luck .

but i don't know why i am getting this error even i don;t use this packages in my code now but still facing this issue .

please help me .,.!

srihari9n commented 2 years ago

@vijayvaghela72

"Transitive dependency" means your program depends on it, because of a dependency you have that depends on it.

To find out which of your dependencies uses which other dependency, you can run:

flutter pub deps

It will show you a dependency tree with version numbers. Check which package is using flutter_inappwebview and then remove that dependency too.

cvphat commented 2 years ago

even for this issue i have done flutter setup again , but still no luck .

but i don't know why i am getting this error even i don;t use this packages in my code now but still facing this issue .

please help me .,.!

Some of packages in your pubspec are using it

add below to your pubspec to override

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master
vijayvaghela72 commented 2 years ago

Thank You so Much For Your Help ...! @rshrc @srihari9n @cvphat ....!

I really appreciate your efforts :)

and your instance reply and clear explanation ..! finally I've solve my issue .

sdfadsfsdf commented 2 years ago

Same situation. Is there any plan to solve this problem? Because I can't use the forked one.

Sunsiha commented 2 years ago

9.2.0

did u find any?

developer-caleb commented 2 years ago

I solved this problem,-> if create new project, it works well , and copy grade.properties, gradle-wrapper.properties, build.gradle from new project to target project. It will work, even if you still use compileSdkVersion 33

srihari9n commented 2 years ago

@developer-caleb would you be able to post the differences between those old and new files here? It will be very helpful.

developer-caleb commented 2 years ago

@developer-caleb would you be able to post the differences between those old and new files here? It will be very helpful. app/build.gradle
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }

apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.google.gms.google-services'

android { compileSdkVersion 33

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.$yourcompany.$yourproject"
    minSdkVersion 21
    targetSdkVersion 30
    multiDexEnabled true
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
}
namespace 'com.$yourcompany.$yourproject'

}

flutter { source '../..' }

dependencies { implementation 'com.android.support:multidex:1.0.3' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }

cradle-wrapper.properties

Fri Jun 23 08:50:38 CEST 2017

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

project/build.gradle buildscript { ext.kotlin_version = '1.6.10' repositories { google() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:7.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.10'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
}

}

allprojects { repositories { google() jcenter() } }

rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" project.evaluationDependsOn(':app') }

task clean(type: Delete) { delete rootProject.buildDir }

AndroidManifest.xml add -> android:usesCleartextTraffic="true"

if you fix this problem, I will be very happy^^ Good luck!

WaheedHussainHaans commented 2 years ago

even for this issue i have done flutter setup again , but still no luck . but i don't know why i am getting this error even i don;t use this packages in my code now but still facing this issue . please help me .,.!

Some of packages in your pubspec are using it

add below to your pubspec to override

dependency_overrides:
  flutter_inappwebview:
    git:
      url: https://github.com/rshrc/flutter_inappwebview
      ref: master

Any fix to this issue please Could not find a file named "pubspec.yaml" in "/Users/waheed/.pub-cache/git/flutter_inappwebview-a76ed7b1aafb4867517f2ed47dda9e9d15cf32d6". pub get failed (66; Could not find a file named "pubspec.yaml" in "/Users/waheed/.pub-cache/git/flutter_inappwebview-a76ed7b1aafb4867517f2ed47dda9e9d15cf32d6".)

srihari9n commented 2 years ago

@developer-caleb Thank you for your response. Based on your comment I changed

classpath 'com.android.tools.build:gradle:7.2.1' in project/build.gradle

and

distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip in gradle-wrapper.properties

This solved my issue without needing to use @rshrc's fork.

rodomedina commented 1 year ago

Hello good morning, I was researching and I found a quick solution, as I always get good answers I leave you as a solution in a video. I hope it serves you greetings :D

https://youtu.be/JjvFjbC248g

JothamIT commented 1 year ago

Hello.. I encounter this issues now and then and my quick fix has always been, manually changing compile33 to compile34. To do this, follow this steps. Gradle Scripts > build.gradle.kts(module:app) >line7, compileSdk=33 (change this to 34) then sync your project.

github-actions[bot] commented 1 month ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.