skip to Main Content

I’m trying to manage my dependencies in Android Studio and it cannot resolve the Kotlin gradle plugin. I’ve tried manually adding it to my build.gradle using the code from Maven Central and adding it using the project structure feature in Android Studio.

As far as I know everything here is correct, so it should just download it and build.


(project) plugins {
    id 'com.android.application' version '7.2.0' apply false
    id 'com.android.library' version '7.2.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.0-RC2' apply false
    id 'org.jetbrains.kotlin.kapt' version '1.7.0-RC' apply false
}

---

(app) plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}
 
---
   
//Kotlin dependencies (app)
    implementation 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.0-RC'
    implementation 'org.jetbrains.kotlin.kapt:org.jetbrains.kotlin.kapt.gradle.plugin:1.7.0-RC'
    implementation 'com.google.devtools.ksp:symbol-processing-gradle-plugin:1.7.0-RC-1.0.5'
    implementation 'org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.0-RC'
    implementation 'androidx.test:core-ktx:1.4.0'
    implementation 'androidx.test.ext:junit-ktx:1.1.3'
    implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0-RC2'

The details from the failed build are

The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute ‘com.android.build.api.attributes.BuildTypeAttr’ with value ‘debug’, attribute ‘com.android.build.api.attributes.AgpVersionAttr’ with value ‘7.2.0’. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0-RC2:

I’m rather inexperienced in android development, as I’m still a student and I’ve been thrown into a android app project by my school even though i haven’t done the relevant classes. It’s completely possible I’m doing something really obviously incorrect, but I can’t identify it at my current skill level

How do I resolve this? Help would be greatly appreciated as my deadline is coming up soon and I’ve spent all day on this

4

Answers


  1. Remove implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0-RC2' line from the app dependencies and there is no need id 'org.jetbrains.kotlin.kapt' version '1.7.0-RC' apply false in the project plugins

    To solve these problems, my first suggestion to you is to update the Android version to the latest available version (Stable version today is Android Studio Chipmunk), and if the project is new, let Android Studio set and create all the gradle values for you by default from the beginning.

    Login or Signup to reply.
  2. I’m a begginer too and this resolved for me

    Open build.graddle (project) find dependecies and look for this line:

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0-RC2" (or other plugin version)

    Replace with:

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$version_kotlin"

    Login or Signup to reply.
  3. in build.gradle (project) replace

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0"

    with

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version".

    And it working

    Login or Signup to reply.
  4. Open build.graddle (project) find buildscript and look for version_kotlin and copy version number

    then Open build.graddle (project) again and find dependecies and look for this line:

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0" (or other plugin version)

    Replace replace the version number with that copied

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search