0

When trying to work with the new versions of the geolocation or location packages it gives me the following error:

[!] Your project requires a newer version of the Kotlin Gradle plugin. │ │ Find the latest version on │ │ https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update │ │ <path-to-app>/android/build.gradle: │ │ ext.kotlin_version = '<latest-version>

This error gives us the reason that the location and geolocation packages are constantly updated and you need to access the new versions of Kotlin, so if you work with a project before of Flutter, you may have this error, it is very easy to solve it, for this you must access to 'proyecto/android/settings.gradle' You must change the following line of code for the new version of Kotlin, which is currently V 2.0.0 and eliminate the line of code that has V 1.7.10. You must also eliminate the '+' sign.

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
  - id "org.jetbrains.kotlin.android" version "1.7.10" apply false
  + id "org.jetbrains.kotlin.android" version "2.0.0" apply false
}

it should stay like this:

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "2.0.0" apply false
}

CoWith that your project should work correctly

1
  • try this answer
    – A-E
    Commented Jul 9 at 16:33

1 Answer 1

0

Thank you for sharing this solution. I can confirm that it works perfectly fine.

As for me, since I was migrating from a previous Flutter SDK version, the Kotlin dependencies were handled differently in it and the structure for android/settings.gradle was entirely contradicting and confusing. If someone encountered the same fate as me, what I did was to simply backup permissions in my android/app/src/main/AndroidManifest.xml and deleted the entire android folder located at the root of my Flutter app. After that I simply ran the following command:

flutter create . --platforms android

This added the android platform again but this time with updated structure in correspondence with the new SDK. Then I copied back my permissions to the new AndroidManifest.xml and proceeded with the proposed solution above without any issue.

Hope this helps someone.

Not the answer you're looking for? Browse other questions tagged or ask your own question.