简体   繁体   English

org.gradle.kotlin.kotlin-dsl 未找到

[英]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我的 buildSrc/build.gradle.kts

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

I tried everything but still not working我尝试了一切,但仍然无法正常工作

Did you check that Android Studio wasn't running in Offline Mode?您是否检查过 Android Studio 没有在离线模式下运行? Take a look at Preferences/Build, Execution, Deployment/Gradle/Global Gradle settings and see if Offline Work is checked.查看Preferences/Build, Execution, Deployment/Gradle/Global Gradle settings ,看看是否选中了 Offline Work。

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.在您的项目和主目录中尝试清理 Gradle 缓存,然后检查它是否可以工作。 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"如果仍然失败,请尝试将 Gradle 和插件更新到最新版本id("org.gradle.kotlin.kotlin-dsl") version "1.3.2"

I have the same problem and I try gradle --info我有同样的问题,我尝试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.好像是把请求传给了proxy 127.0.0.1:1083。但是我在本地gradle.properties文件中设置proxy的url是127.0.0.1:8118。有什么问题吗?经过长时间的努力,我找到了。
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.实际上,你的系统中有两个 gradle.properties 配置文件,一个在你的项目/.gradle,一个在~/.gradle。后者是 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.如果全局设置为systemProp.http.proxyHost设置了变量,那么无论你在project/.gradle/gradle.properties中设置什么,proxy都不起作用,你必须在全局设置中更改它。
And BTW,I find that the global setting for gradle is changed by my android studio preference.顺便说一句,我发现 gradle 的全局设置被我的 android studio 偏好改变了。

In my case, my company using proxy behind the network.就我而言,我的公司在网络背后使用代理。

So it must SSL handshake fail issue.所以它必须 SSL 握手失败问题。

To fix this issue, I use KeyStore Explorer .为了解决这个问题,我使用KeyStore Explorer

Follow these steps.按着这些次序。

  1. Download KeyStore Explorer and install it on your system.下载 KeyStore Explorer 并将其安装在您的系统上。 (In my case Windows10 OS) (在我的情况下是 Windows10 操作系统)

  2. Run KeyStore Explorer and open cacerts file, if you are using Android Studio on Windows 10 , it's at here: C:\\Program Files\\Android\\Android Studio(or Preview)\\jre\\jre\\lib\\security with password changeit .运行 KeyStore Explorer 并打开cacerts文件,如果您在 Windows 10 上使用Android Studio ,它位于: C:\\Program Files\\Android\\Android Studio(or Preview)\\jre\\jre\\lib\\security with password changeit

  3. On the toolbar, go to Examine -> Examine SSL , and insert these values and click OK .在工具栏上,转到“ Examine -> Examine SSL ,然后插入这些值并单击“ OK

    SSL Host: plugins.gradle.org SSL 主机: plugins.gradle.org
    SSL Port: 443 SSL 端口: 443

  4. Click the Import button and OK .单击“ Import按钮和“ OK

  5. Save the file, and go to Android Studio, run Invalidate Caches / Restart . Save文件,然后转到 Android Studio,运行Invalidate Caches / Restart

  6. If Android Studio is reopened, try Sync Project with Gradle Files again.如果 Android Studio 重新打开,请再次尝试将Sync Project with Gradle Files

Please leave comment, if you have more questions.如果您有更多问题,请发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.gradle.api.plugins.UnknownPluginException-'org.gradle.kotlin.kotlin-dsl - org.gradle.api.plugins.UnknownPluginException - 'org.gradle.kotlin.kotlin-dsl Android Gradle:未找到 ID 为“XXXX”的自定义插件 - Kotlin DSL - Android Gradle: Custom Plugin with id 'XXXX' not found - Kotlin DSL Gradle Kotlin DSL的versionCodeOverride等效项 - versionCodeOverride equivalent for Gradle Kotlin DSL Gradle Kotlin DSL中Dynatrace的配置 - Configuration of Dynatrace in Gradle Kotlin DSL Kotlin崩溃无法将提供的表示法转换为依赖类型的对象:org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension_Decorated - Kotlin crash Cannot convert the provided notation to an object of type Dependency: org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension_Decorated 如何使用 Kotlin dsl gradle 启用代码覆盖率? - How to enable code coverage with Kotlin dsl gradle? Fabric Beta发行说明和Gradle Kotlin DSL - Fabric Beta release notes and Gradle Kotlin DSL isCoreLibraryDesugaringEnabled 在 gradle kotlin dsl / kts 中不起作用 - isCoreLibraryDesugaringEnabled not works in gradle kotlin dsl / kts Jetpack 原型数据存储 - gradle 配置和 Kotlin dsl - Jetpack proto datastore - gradle config with Kotlin dsl 使用 Kotlin DSL 迁移 Android Gradle 插件 7.0.0 - Android Gradle Plugin 7.0.0 migration with Kotlin DSL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM