Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.71'] was not found in any of the following sources
Asked Answered
R

21

51

I have a fresh install of IntelliJ, I created a new kotlin gradle project using the following settings:

Project settings

This produces the following build.gradle.kts, (the exact same file works on my Windows machine):

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.2.71"
}

group = "com.test"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    compile(kotlin("stdlib-jdk8"))
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}

Which produces this error, when trying to do a gradle refresh:

Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.71'] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.2.71') Searched in the following repositories: Gradle Central Plugin Repository
Rhyne answered 28/9, 2018 at 21:13 Comment(6)
Please check that "Offline" option is not enabled in "Settings | Build... | Build Tools | Gradle"Mukerji
@y.bedrov, it is not enabled.Rhyne
Did you manage to solve this? Considering just using a build.gradle insteadFutures
I have the same issue with build.gradle, so I don't think it's related to the Kotlin DSL build script (on macos).Gallager
I have the same problem with both using build.gradle or Kotlin DSL as well. Different PC, same internet connection it works. Tried to invalidate IntelliJ cache to no avail.Tripe
In my case I didn't specify a version for kotlin("jvm"), maybe it helps someone.Henrieta
S
25

Check your Internet connection and make sure your Internet is not restricted.

I solved this problem by turning on proxy for all tunnels (not just HTTP) with a VPN app.

Sowell answered 22/10, 2018 at 3:27 Comment(2)
VPN was solved my problemMarathon
Restarting my router worked!Frenchy
U
10

check if you are not in gradle offline mode

enter image description here

Urba answered 16/5, 2023 at 10:47 Comment(2)
this one is my case! !!!Latish
Restarting my router worked!Frenchy
E
8

Check your gradle and kotlin (or Java) versions.

I got the same error and my issue is solved by specifying the kotlin version in build.gradle:

Before:

plugins {
    id 'org.jetbrains.kotlin.jvm'
}

After:

plugins {
    id 'org.jetbrains.kotlin.jvm' version "1.4.10"
}
Erfurt answered 23/8, 2021 at 12:46 Comment(1)
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.kotlin.jvm'] was not found in any of the following sourcesTayyebeb
K
6
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
//    kotlin("jvm") version "1.2.71"
}

group = "com.test"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    compile(kotlin("stdlib-jdk8"))
}

//tasks.withType<KotlinCompile> {
//    kotlinOptions.jvmTarget = "1.8"
//}
  1. gradle sync by commenting the above lines. The gradle will be set up.
  2. once the gradle is downloaded, uncomment those line and sync again.
  3. if the dependencies are not downloaded properly, run 'gradle build' in the terminal and click on gradle sync.

This solved the issue for me.

Kelikeligot answered 7/4, 2020 at 16:25 Comment(1)
Welcome to Stack Overflow. If you want to improve your answer please use the edit button instead of adding a comment. Comments should be used for asking for more information or for suggesting improvements.Distaste
C
5

(1) in my case (OpenJDK 11 on Ubuntu 18.04) the problem was Gradle not being able to download the POM file from gradle plugin-server. you can test it by entering this line into jshell:

new java.net.URL("https://plugins.gradle.org/m2/org/jetbrains/kotlin/jvm/org.jetbrains.kotlin.jvm.gradle.plugin/1.3.11/org.jetbrains.kotlin.jvm.gradle.plugin-1.3.11.pom").openStream()

(you can find your url by running gradle with --debug option)

So if you received an exception like this: InvalidAlgorithmParameterException: trustAnchors parameter must be non-empty then the trouble is CA-certs cache. which could be easily fixed by writing these lines into bash Ref:

sudo su
/usr/bin/printf '\xfe\xed\xfe\xed\x00\x00\x00\x02\x00\x00\x00\x00\xe2\x68\x6e\x45\xfb\x43\xdf\xa4\xd9\x92\xdd\x41\xce\xb6\xb2\x1c\x63\x30\xd7\x92' > /etc/ssl/certs/java/cacerts
/var/lib/dpkg/info/ca-certificates-java.postinst configure

By the way do not forget to restart gradle daemon before trying again. (gradle --stop)

(2) another reason could be your internet not having access to bintray.com (the internet of Iran or China) which you can test by putting this line on jshell :

new java.net.URL("https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.3.11/kotlin-gradle-plugin-api-1.3.11.pom").openStream()

If you received a connection timeout, it confirms this theory. In this case you need to buy and have proxy/vpn connected in order to be able to download these dependencies.

Chatterton answered 25/12, 2018 at 11:8 Comment(1)
Thanks, no verbosity level for gradle would point out that the certificate wasnt beign recognized, and as I could get the pom from the browser i had no clue why it wasnt working. Testing it from jshell like you suggested made it pretty clear to me. What i just can't understand is why my JVM out of nowhere decided it doesnt trust the main gradle plugin repository... Java is painfullHumpy
D
5

I updated my Kotlin version to 1.7.20 and fixed this problem.

id 'org.jetbrains.kotlin.android' version '1.7.20' apply false

Dictograph answered 3/12, 2022 at 20:15 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Circle
This fixed the problem for me. Thanks! I tried all the solutions above and they didn't work in my caseProstration
H
4

If you are using java like me .I got the issue fixed by adding the following:

Root gradle

dependencies {
        ext.kotlin_version = '1.4.10'

        classpath "com.android.tools.build:gradle:7.0.4"
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        ......
    }

App gradle file

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

    dependencies {
        implementation "com.google.dagger:hilt-android:2.38.1"
        kapt "com.google.dagger:hilt-compiler:2.38.1"
        ......

    }
Holsworth answered 23/1, 2022 at 20:31 Comment(0)
C
3

In my case the problem was because Charles Proxy. After closing Charles I could start working again

Composite answered 29/6, 2021 at 23:20 Comment(1)
it sloved my problemMegmega
P
3

In my case (Ubuntu 20.04), problem was with gradle 7.2, installed from snap.

I have removed gradle 7.2, installed from snap and install gradle 7.2 from sdkman. Works fine for me.

Postrider answered 27/9, 2021 at 9:28 Comment(0)
T
2

Ok, so the answer was very simple all along. For some reason I activated gradle's "Offline work" toggle and that was the cause of the problem.

To disable it simply go to Settings > Build, Execution, Deployment > Build Tools > Gradle and deselect the "Offline work" checkbox.

Tripe answered 10/6, 2019 at 17:15 Comment(1)
In IDEA 2022.3, there is no checkbox, so I thought this was irrelevant. Then I saw that .idea > gradle.xml had the following line: <option name="offlineMode" value="true" />, which should be removed. So annoying.Keavy
K
1

In my case I changes the Gradle JVM in Settings > Build, Execution, Deployment > Build Tools > Gradle and it worked.

Kellikellia answered 28/7, 2021 at 16:38 Comment(0)
L
1

Disconnect from your VPN (or make sure you have an open internet connection), then restart Android Studio.

If you don't restart it sometimes it continues with invalid proxy properties.

Lallygag answered 27/10, 2022 at 17:21 Comment(0)
S
1

[https://github.com/facebook/react-native/issues/38853][1]

React Native says: If you already have a JDK on your system, we recommend JDK17. You may encounter problems using higher JDK versions.

If you're using the latest version of Java Development Kit, you'll need to change the Gradle version of your project so it can recognize the JDK. You can do that by going to{project root folder}\android\gradle\wrapper\gradle-wrapper.properties and changing the distributionUrl value to upgrade the Gradle version. You can check out here the latest releases of Gradle.

Things that worked for me was to run the following command : choco install -y microsoft-openjdk17 to install the correct version of JDK and install the required Android SDK's and ensure that they are corrctly present in the environment Variables.

Copy and paste Get-ChildItem -Path Env:\ into powershell to verify that JAVA_HOME and ANDROID_HOME path is present in environment variables

Seaward answered 19/3 at 12:24 Comment(1)
It is Basically about the incorrect JDK version for React Native, if this solution doesn't works trying checkin all the versions of node, Jdk, android Sdk, kotlin and gradleSeaward
P
0

I recently had similar issue with an empty project autogenerated by Intellij Idea.

Solved this problem by combining Java and Gradle versions.

Initially I had Oracle Java 8 with Gradle 6.8.3.

After several attempts I found a working combination - AdoptOpenJDK 11 and Gradle 5.6.4

Pict answered 31/3, 2021 at 23:27 Comment(0)
A
0

This for Ktor devs. If you are working on a ktor application with the web project generator there is a chance the generator sets invalid jvm plugin version. So make sure you are setting correct version for jvm plugin. You can find the latest jvm plugin version here. Here is the sample build.gradle.kts file.

//Plugin section
plugins {
    kotlin("jvm") version "1.8.0"
    id("io.ktor.plugin") version "2.2.2"
}

//Dependancy section
dependencies {
   ...

   testImplementation("io.ktor:ktor-server-tests-jvm:1.8.0")
   testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.8.0")

   ...
}
Amphiarthrosis answered 29/1, 2023 at 6:27 Comment(0)
P
0

I was getting Could not find org.jetbrains.kotlin:kotlin-scripting-jvm:1.8.20.

This is because the generated build.gradle uses the kotlin_version to get the jvm and as of right now there is no 1.8.20 version. there are only RC versions of the JVM for that version. enter image description here

I changed the version to 1.2.10 and it built just fine. So if you come across this, check here to see if plugins.kotlin("jvm") version is using a version that doesn't yet exist.

Prepared answered 30/3, 2023 at 18:11 Comment(0)
E
0

gradle --stop after npx react-native run-android wordked for me

Eada answered 12/4, 2023 at 15:28 Comment(0)
Z
0

in my case BurpSuite was on and as soon as I closed it everything was working.

Zabrina answered 17/9, 2023 at 9:1 Comment(0)
A
0

I encountered a similar issue where I received the error: "Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.8.21'] was not found in any of the following sources". This happened after migrating my Kotlin project to use an organization-specific artifact repository. The problem was resolved by correctly configuring the pluginManagement section in the settings.gradle.kts file.

When switching to a different artifact repository, it's crucial to specify the new repository in the pluginManagement block so Gradle knows where to find the required plugins. Here’s how I updated my settings.gradle.kts:

pluginManagement {
    repositories {
        mavenLocal()
        maven {
            url = uri("<repository url>") // Replace with your actual repository URL
            credentials {
                username = "<user>" // Replace with your repository username
                password = "<pass>" // Replace with your repository password
            }
        }
        // You can also include the Gradle Plugin Portal if needed
        gradlePluginPortal()
    }
}
Account answered 28/11, 2023 at 22:55 Comment(0)
F
0

gradle.properties content was my issue... I tried to create new project in IntelliJ Idea after several days of searching and testing a lot of solutions. And I could see that my gradle.properties contains several rows more than the new one:

kotlin.code.style=official // this line only remains

systemProp.http.proxyHost=localhost
systemProp.http.proxyPort=9001

systemProp.https.proxyHost=localhost
systemProp.https.proxyPort=9001

so I deleted rows with systemProp... and it works now! :)

Fidelity answered 12/12, 2023 at 10:57 Comment(0)
W
0

Upgrade your kotlin plugin version to the latest version in the build.gradle project file like this

before - id 'org.jetbrains.kotlin.android' version '1.8.0' apply false

after - id 'org.jetbrains.kotlin.android' version '1.9.22' apply false

this worked for me

Windage answered 11/2 at 8:17 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Circle

© 2022 - 2024 — McMap. All rights reserved.