在gradle更新后无法找到方法(无法编译项目) [英] Unable to find method (can't compile project) after gradle update
问题描述
我尝试将我的项目中的gradle版本更新为4.1-milestone-1,并遵循这些说明
我当前的gradle-wrapper.properties文件:
#Sat Jun 17 17:17:43 IDT 2017
distributionBase = GRADLE_USER_HOME
distributionPath =包装/ dists
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper / dists
distributionUrl = \
https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
我目前的项目build.gradle文件buildscript
buildscript {
ext.kotlin_version ='1.1.3'
适用于:'dependencies.gradle'
仓库{
jcenter()
mavenCentral()
google()
}
依赖关系{
classpath'com.android.tools.bui ld:gradle:3.0.0-alpha5'
....
}
....
}
当尝试编译项目时,出现以下错误:
错误: (1,0)无法找到方法
'com.google.common.base.Preconditions.checkArgument(ZLjava / lang / String; Ljava / lang / Object; Ljava / lang / Object; Ljava / lang / Object; Ljava /郎/对象;)V。
这种意外错误的可能原因包括:在损坏的Gradle进程中,您可以
- Gradle的
依赖关系缓存可能已损坏(有时发生在网络
连接超时之后。)重新下载依赖关系
和同步项目(需要网络)- Gradle
构建过程(守护进程)的状态可能已损坏。停止所有的Gradle守护进程可能
解决了这个问题。停止Gradle构建
进程(需要重新启动)- 您的项目可能使用
第三方插件,该插件与
中的其他插件不兼容
项目请求的Gradle版本。
关闭IDE,然后终止所有Java进程。
-
我试着清理项目
p>我尝试点击重新下载依赖项并同步项目,但是我得到 -
我试图杀死所有的gradle的守护进程,但是我得到了同样的错误。
的同样错误。 我删除了以前的.gradle文件在我的主目录和我的
项目中,但我得到了同样的错误。 我试图杀死java进程和android studio,但是我得到
同样的错误。
问题在于我的build脚本中有firebase所以它看起来像这样:
buildscript {
ext.kotlin_version ='1.1.3-2'
适用于:'dependencies.gradle'
存储库{
...
}
依赖项{
classpath'com.android.tools.build: gradle:3.0.0-alpha6'
classpath('com.google.firebase:firebase-plugins:1.1.0')// firebase line
....
}
$ / code>
我最终通过将firebase classpath行替换为这个来解决问题:
classpath('com.google.firebase:firebase-plugins:1.1.0'){
exclude group:'com.google .guava',module:'guava-jdk5'
}
现在我的gradle build脚本看起来像这样
buildscript {
ext.kotlin_version ='1.1.3-2'
适用于:'dependencies.gradle'
repositories {
...
}
依赖关系{
classpath'com.android.tools.build:gradle:3.0.0-alpha6'
classpath('com.google .firebase:firebase-plugins:1.1.0'){
exclude group:'com.google.guava',module:'guava-jdk5'
}
....
$ p 之后,我所要做的就是清理项目,杀死gradle守护进程
./ gradlew --stop
然后重启studio,问题就解决了。
I tried to update the gradle version in my project to 4.1-milestone-1 following these instructions
My current gradle-wrapper.properties file:
#Sat Jun 17 21:17:43 IDT 2017
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
My current project build.gradle file buildscript
buildscript {
ext.kotlin_version = '1.1.3'
apply from: 'dependencies.gradle'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
....
}
....
}
When trying to compile the project I get this error:
Error:(1, 0) Unable to find method
'com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V'.
Possible causes for this unexpected error include:
- Gradle's
dependency cache may be corrupt (this sometimes occurs after a network
connection timeout.) Re-download dependencies
and sync project (requires network)
- The state of a Gradle
build process (daemon) may be corrupt. Stopping all Gradle daemons may
solve this problem. Stop Gradle build
processes (requires restart)
- 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.
In the case of corrupt Gradle processes, you can
also try closing the IDE and then killing all Java processes.
I tried cleaning the project
I tried to click re-download dependencies and sync project, but I get
the same error.
I deleted my previous .gradle file in my home directory and in my
project but I get the same error.
I tried killing the java process and android studio but I get the
same error.
I tried killing all gradle's daemons but I get the same error
解决方案 The problem was that I had firebase in my buildscript dependencies, so it looked something like this:
buildscript {
ext.kotlin_version = '1.1.3-2'
apply from: 'dependencies.gradle'
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
classpath ('com.google.firebase:firebase-plugins:1.1.0') //the firebase line
....
}
}
I finally solved the issue by replacing the firebase classpath line with this:
classpath ('com.google.firebase:firebase-plugins:1.1.0') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
So now my gradle build script looks something like this
buildscript {
ext.kotlin_version = '1.1.3-2'
apply from: 'dependencies.gradle'
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
classpath ('com.google.firebase:firebase-plugins:1.1.0') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
....
}
}
After that, all I had to do was clean the project, kill the gradle daemon
./gradlew --stop
And restart studio, and the issue was solved.
这篇关于在gradle更新后无法找到方法(无法编译项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!