1

I would like to use flutter-web plugin in my app. However, I am getting the following SDK error when I add it to my YAML file. I just upgraded to 1.20.4

How do I fix this error?

The current Flutter SDK version is 1.20.4.

Because app depends on webview_flutter >=1.0.0 which requires Flutter SDK version >=1.22.0 <2.0.0, version solving failed. pub get failed (1; Because app depends on webview_flutter >=1.0.0 which requires Flutter SDK version >=1.22.0 <2.0.0, version solving failed.)

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 12.0) [✓] Android Studio (version 3.6) [✓] VS Code (version 1.49.2) [✓] Connected device (1 available)

• No issues found!

This is the info in my pubspec.yaml file

environment: sdk: ">=2.2.2 <3.0.0"

3 Answers 3

5

webview_flutter package need minSdkVersion 19 so you have to change the app level gradle

android {
    defaultConfig {
        // Required by the Flutter WebView plugin.
        minSdkVersion 19
    }
  }

after upgrade your flutter using flutter upgrade

and then import webview_flutter In your pubspec.yaml file webview_flutter: ^1.0.0 because webview_flutter is stable in flutter 1.22 stable release.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. so, if I change to minSdkVersion to 19 (currently 16). Would that mean that android user whose phone <=16 will not be able to use the app
yes, @user2570135 user below 19 is not able to use it.
0

I was facing the same problem but I did not know the path of that build.gradle so I found it after spending some time.

You have to edit the build.gradle file. In a flutter project, it is found at the path ./android/app/build.gradle.

The parameter that needs to be changed is, of course, minSdkVersion 16, bumping it up to what you need (in this case 19).

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.web_view_example"
    minSdkVersion 19 //This is what you need to change.
    targetSdkVersion 31
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

Comments

0

For my case, I'm using linkedin_login: ^2.2.1 mean which LinkedIn lib also using webview (iOS is working) but Android it requires to downgrade minSDKVersion to 16. Please open android folder as Android Project in order to see like this. Hope it help you too. enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.