Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher
Asked Answered
L

6

15

error: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher. The following dependencies do not satisfy the required version: project ':ar_flutter_plugin' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

android/build.gradle

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

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


Levirate answered 5/11, 2022 at 15:36 Comment(1)
How did you resolved it?Forequarter
E
25

I actually tried to solve this problem in Flutter: enter image description here

I found a solution for that here:

Why am I getting this warning and how to resolve it "This version only understands SDK XML versions up to 2 but an SDK XML..."

But then I ran into similar problem as yours.

AFAIK the main problem is the limitations in the libraries we are using, and that it isn't prepared for the level we want to.

If you use AS and look here:

enter image description here

under Flutter plugins, and find the module which is complaining

enter image description here

In my case it was "location:", and if you expand the "android" folder here you can find the contents of the gradle file:

enter image description here

AS you see, the level of 'ext.kotlin_version' is 1.4.20, which is too low.

Either we need to find a new provider to our libraries, try to convince the creator to release an updated version, or try to manually change it (I personally don't like to tamper with libraries that way).

Edelstein answered 10/11, 2022 at 11:44 Comment(2)
Exactly what I discovered - however there is a fork of this plugin that is updated: pub.dev/packages/flutter_timezoneAbaddon
@Abaddon same issue with flutter_native_timezone.Speculation
B
3

I encountered this error using the receive_sharing_intent package. Turns out the com.android.tools.build dependency was out of date.

Pull Request

Until that gets merged you can use this dependency statement:

receive_sharing_intent:
  git:
    url: https://github.com/Thogsit/receive_sharing_intent
Bodrogi answered 4/3, 2023 at 0:55 Comment(0)
P
1

What helped me was using the ar_flutter_plugin_flutter package. As its creator indicates, this version is a direct adaptation of the original ar_flutter_plugin, maintaining all its powerful features and capabilities. This fork was created because the original plugin hadn't been updated since 2022. This package includes the Gradle update, which makes that error disappear.

Plasm answered 12/2 at 20:31 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Freestanding
F
0

replaced

location: ^4.4.0

with this in pubspec.yaml and ran flutter pub get

  location:
    git:
      url: https://github.com/781flyingdutchman/flutterlocation.git
      ref: 'V4'
      path: packages/location

Facing answered 27/6, 2023 at 8:28 Comment(0)
T
0

Add this to your android/build.gradle

subprojects {
    beforeEvaluate { project ->
        if (project.name == "ar_flutter_plugin") {
            project.buildscript.dependencies.classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
        }
    }
}
Tricotine answered 1/8 at 12:48 Comment(0)
H
-1

Follow these steps to resolve this issue:

  • Open the Flutter project.
  • Find Flutter plugins.
  • Find location4.4.0.
  • Go to the android and then open the build.gradle.
  • Change the Kotlin version to the latest.
Helminthiasis answered 13/6, 2023 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.