Charming Wong
Charming Wong

Reputation: 121

org.gradle.kotlin.kotlin-dsl was not found

I am getting the following error while running the build

FAILURE: Build failed with an exception.

* Where:
Build file '/home/charming/mainframer/bigovlog_android/buildSrc/build.gradle.kts' line: 4

* What went wrong:
Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '1.2.6'] 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.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:1.2.6')
  Searched in the following repositories:
    Gradle Central Plugin Repository

my buildSrc/build.gradle.kts

repositories {
    jcenter()
}
plugins {
    `kotlin-dsl`
    id("groovy")
}
dependencies{
    gradleApi()
    localGroovy()
}

I tried everything but still not working

Upvotes: 10

Views: 33206

Answers (5)

mmdreza baqalpour
mmdreza baqalpour

Reputation: 1473

I was updating my gradle to 8.2. After facing this problem I just added gradlePluginPortal() into my repositories. This solved the problem.

Upvotes: 4

wonsuc
wonsuc

Reputation: 3635

In my case, my company is using a proxy behind the network.

So it must be an SSL handshake fail issue.

To fix this issue, I use KeyStore Explorer.

Follow these steps.

  1. Download KeyStore Explorer and install it on your system. (In my case Windows10 OS)

  2. Run KeyStore Explorer and open the cacerts file, if you are using Android Studio on Windows 10, it's here: C:\Program Files\Android\Android Studio(or Preview)\jre\jre\lib\security with password changeit.

  3. On the toolbar, go to Examine -> Examine SSL, insert these values and click OK.

    SSL Host: plugins.gradle.org
    SSL Port: 443

  4. Click the Import button and OK.

  5. Save the file, and go to Android Studio, run Invalidate Caches / Restart.

  6. If Android Studio is reopened, try Sync Project with Gradle Files again.

Please leave a comment, if you have more questions.

Upvotes: 7

傅继晗
傅继晗

Reputation: 1137

I have the same problem and I try gradle --info
the log is below:

Evaluating project ':buildSrc' using build file '/Users/fjh1997/mirai/buildSrc/build.gradle.kts'.
I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {tls}->http://127.0.0.1:1083->https://plugins.gradle.org:443: The target server failed to respond
Retrying request to {tls}->http://127.0.0.1:1083->https://plugins.gradle.org:443
I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {tls}->http://127.0.0.1:1083->https://plugins.gradle.org:443: The target server failed to respond
Retrying request to {tls}->http://127.0.0.1:1083->https://plugins.gradle.org:443
I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {tls}->http://127.0.0.1:1083->https://plugins.gradle.org:443: The target server failed to respond

It seems that pass requests to proxy 127.0.0.1:1083.However what url I set proxy in local gradle.properties file is 127.0.0.1:8118.What's wrong with that?After long time's efforts,I find it out.
Actually,there are two gradle.properties configuration files in your system , one is in your project/.gradle,another is in ~/.gradle.And the latter is the global setting for gradle.
If the global setting has set variables for systemProp.http.proxyHost, then whatever you set in project/.gradle/gradle.properties, proxy dosen't work at all,you have to change it in the global setting.
And BTW,I find that the global setting for gradle is changed by my android studio preference.

Upvotes: 1

diemer
diemer

Reputation: 409

Did you check that Android Studio wasn't running in Offline Mode? Take a look at Preferences/Build, Execution, Deployment/Gradle/Global Gradle settings and see if Offline Work is checked.

Upvotes: 17

Alexander Mikhalchenko
Alexander Mikhalchenko

Reputation: 619

The same exact build file works for me. Try clean Gradle cache in both your project and home directory and check if it will work then. If it will still fail, try to update Gradle and the plugin to the latest version id("org.gradle.kotlin.kotlin-dsl") version "1.3.2"

Upvotes: 1

Related Questions