FAILURE: Build failed with an exception.
* What went wrong:
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 ':location' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Is there a question hidden somewhere?
This is the typical cause to your problem. It seems you are essentially trying to build Kotlin sources from an Android application module (:location) using the Kotlin Gradle Plugin and the Kotlin toolchains, and that requires a minimum Kotlin Gradle plugin of 1.5.20, while yours is 1.4.20.
Attempt to fix the issue:
Make sure to update the kotlin Gradle plugin version via the plugins closure, if you are using Groovy DSL, you can use this:
plugins {
// Replace `<...>` with the plugin name appropriate for your target environment
id 'org.jetbrains.kotlin.android' version '2.0.20'
}
Here is the page to the Kotlin plugin you are using:
https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android
KGP essentially links your application build lifecycle (managed by the AGP) with the Kotlin compiler to provide the AGP with the appropriate bytecode via registering pre-compiled Gradle tasks that compiles your Kotlin sources and links them with the Android SDK for dexing and packaging into an Android APK.
EDIT:
In case you are still using the legacy plugin, then it will be something like this in your build.gradle
:
buildscript {
ext.kotlin_version = '2.0.20'
ext.agp_version = '8.1'
repositories {
google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath "com.android.tools.build:gradle:$agp_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
...