[英]Android Studio 3.0 Canary 5 - Error:Unable to load class 'org.gradle.api.internal.component.Usage'
I have read through all of the existing stack questions relating to this and their solutions did not help me. 我已经阅读了与此相关的所有现有堆栈问题,他们的解决方案对我没有帮助。
The error: 错误:
Error:Unable to load class 'org.gradle.api.internal.component.Usage'.
错误:无法加载类'org.gradle.api.internal.component.Usage'。 Possible causes for this unexpected error include:
此意外错误的可能原因包括:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
Gradle的依赖缓存可能已损坏(这有时会在网络连接超时后发生。)重新下载依赖项并同步项目(需要网络)
- The state of a Gradle build process (daemon) may be corrupt.
Gradle构建过程(守护程序)的状态可能已损坏。 Stopping all Gradle daemons may solve this problem.
停止所有Gradle守护进程可以解决此问题。 Stop Gradle build processes (requires restart)
停止Gradle构建过程(需要重启)
- Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的Gradle版本不兼容。
在损坏的Gradle进程的情况下,您还可以尝试关闭IDE,然后终止所有Java进程。
gradle-wrapper.properties gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
Project build.gradle 项目build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
classpath "io.realm:realm-gradle-plugin:0.89.1"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Settings Gradle 设置Gradle
Use default gradle wrapper
Module Settings 模块设置
Compile Sdk Version: API 26
Build Tools Version: 26.0.0
I believe these are all the latest available. 我相信这些都是最新的。 And I have tried invalidate caches & restart / rebooting the machine
我尝试过无效的缓存并重启/重启机器
I tried all the above suggestions for deleting cache and nothing worked for me. 我尝试了以上所有删除缓存的建议,对我来说没什么用。 In the end, the problem was the plugin
com.novoda:bintray-release:0.4.0
. 最后,问题是插件
com.novoda:bintray-release:0.4.0
。 When I upgraded it to 0.5.0
, it worked. 当我将其升级到
0.5.0
,它有效。
I would take a hard look at your gradle plugins! 我会仔细看看你的gradle插件!
Delete Gradle cache C:/users/<yourname>/.gradle
(delete the whole directory actually). 删除Gradle缓存
C:/users/<yourname>/.gradle
(实际删除整个目录)。 Then upgrade Gradle and try again. 然后升级Gradle并再试一次。
Or if you are using Gradle wrapper go into properties and upgrade the version of the wrapper ./gradle/wrapper/gradle-wrapper.properties
或者,如果您正在使用Gradle包装器,请转到属性并升级包装器的版本
./gradle/wrapper/gradle-wrapper.properties
Your question doesn't specify the versions, then I assume this might be your problem. 您的问题没有指定版本,那么我认为这可能是您的问题。
Edit: Check if your plugins are still Compatible with your version of Gradle 编辑:检查您的插件是否仍然与您的Gradle版本兼容
io.realm:realm-gradle-plugin:0.89.1
seems a bit old there is a version 3.5.0
already io.realm:realm-gradle-plugin:0.89.1
似乎io.realm:realm-gradle-plugin:0.89.1
版本已经有3.5.0
版
Since Gradle 3.4
Usage
was renamed to UsageContext
and maybe one of your plugins, or dependencies is not compatible with Gradle 4.1-milestone
that you are using by looking at the distribution Url. 由于
Gradle 3.4
Usage
已重命名为UsageContext
并且可能是您的某个插件,或者依赖项与您正在使用的Gradle 4.1-milestone
不兼容,请查看分发Url。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.