Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 308
Morgoth Avatar asked Sep 28 '18 21:09

Morgoth


People also ask

What is kotlin JVM?

Kotlin is a general purpose, free, open source, statically typed “pragmatic” programming language initially designed for the JVM (Java Virtual Machine) and Android that combines object-oriented and functional programming features. It is focused on interoperability, safety, clarity, and tooling support.

What is kotlin kapt?

Kapt is the Kotlin Annotation Processing Tool, and it's in pretty good shape these days. If you want to be able to reference generated code from Kotlin, you need to use kapt. To do that, simply include the plugin in your build.gradle file with the line: apply plugin: 'kotlin-kapt'

What is the latest version of Kotlin?

Kotlin 1.6 was released in November 2021. Kotlin 1.7 was released in June 2022, including the alpha version of the new Kotlin K2 compiler.


8 Answers

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.

like image 145
Shreck Ye Avatar answered Oct 02 '22 23:10

Shreck Ye


(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.

like image 29
NiMa Thr Avatar answered Oct 03 '22 00:10

NiMa Thr


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.

like image 35
Harshith Patte Avatar answered Oct 03 '22 01:10

Harshith Patte


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.

like image 42
MMauro Avatar answered Oct 03 '22 01:10

MMauro


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

like image 22
Jorge Casariego Avatar answered Oct 02 '22 23:10

Jorge Casariego


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.

like image 33
Виталий Жаков Avatar answered Oct 03 '22 01:10

Виталий Жаков


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"
        ......

    }
like image 33
Ian TK Avatar answered Oct 03 '22 00:10

Ian TK


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"
}
like image 43
AMK Avatar answered Oct 03 '22 00:10

AMK