Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dependency 'androidx.webkit:webkit:1.5.0' requires 'compileSdkVersion' to be set to 32 or higher

According to the documentation for "webview_flutter", the package requires Android SDK 20+. Immediately after running flutter pub add webview_flutter and restarting my app (without even attempting to use WebView yet), I’m greeted with the following error:

One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to /Users/chris/Projects/app/android/app/build.gradle:
android {
  compileSdkVersion 32
  ...
}


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > One or more issues found when checking AAR metadata values:

     Dependency 'androidx.webkit:webkit:1.5.0' requires 'compileSdkVersion' to be set to 32 or higher.
     Compilation target for module ':app' is 'android-31'

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

The device I’m testing on and compiling for is running version 31.

My android/app/build.gradle file:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

...

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

android {
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    ...

    defaultConfig {
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    ...
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

I’ve also attempted to change the minSdkVersion to what the docs suggest, to no avail:

android {
    defaultConfig {
        minSdkVersion 20
    }
}

I’ll happily use an older version of webkit if it allows the compile sdk version to be lower, but I’ve tried flutter_webview versions 1.0.7 and 2.8.0 with the same result. How do I avoid this seemingly restrictive behaviour?

Will changing the compileSdkVersion to 32 as it suggests, still allow me to support devices using 31 or lower?

>Solution :

compileSdkVersion is the SDK version used to compile your app, has nothing to do with the Android version your device has.

Any compileSdkVersion will work on any device you have.
32 and 31 are almost the same, 31 is Android 12 and 32 is Android 12L, so if you are already using 31 is safe to use 32.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading