'Plugin [id: 'org.jetbrains.kotlin.android', version: '1.6.21', apply: false] was not found in any of the following sources:

I started learning Kotlin in Android studio a few days ago and I still haven't figured it all out, so having this problem is a big question mark for me, I know nothing yet about gradle. Screen of faild gradle

I just created a new empty activity and it suddenly appears out of nowhere.

this is my buildgradle file :

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

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


Solution 1:[1]

So the problem is now solved .... for some reason. I just want to add that I really don't understand why (in case someone wants to help me haha).

I tried to open another project, in another widow and I did exactly the same thing. I created a new empty activity to see if the problem was with my computer or the internet. But it wasn't. Everything worked perfectly well. No gradle problems. So I closed the second project, with the idea of really trying to find an answer for my main project, but suddenly it just... worked. I did NOTHING. I just opened a second project.

I really don't get it.

Solution 2:[2]

The same thing happened to me. I just created a new project and the problem is solved.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Célia
Solution 2 Asgwani