8

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

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Even when I remove the string, It fails to resolve the plugin albeit at a different version then I'm specifying
plugins { id 'com.android.application' version '7.2.1' apply false id 'com.android.library' version '7.2.1' apply false id 'org.jetbrains.kotlin.android' version '1.6.21' apply false }
Put the piece of code I commented on above and test it, also change your versions to latest stable version = 1.6.21
(in the module gradle)-> plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'kotlin-kapt' }
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"

Comments

1

1- read the warning message 2- if gaude you to increase or decrease the Gradle version go to build. Gradle then makes the gradle version as you have in android studio in my case I decrease from 7.3.0 to 7.2.2

7:08 AM Gradle sync failed: The project is using an incompatible version (AGP 7.3.0) of the Android Gradle plugin. The latest supported version is AGP 7.2.2

plugins { id 'com.android.application' version '7.2.2' apply false id 'com.android.library' version '7.2.2' apply false id 'org.jetbrains.kotlin.android' version '1.7.10' apply false } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.