更新后Gradle项目同步失败-无法找到方法'com.google.common.collect.ImmutableSet.toImmutableSet()Ljava / util / stream / Collector;'

时间:2018-06-28 18:36:23

标签: android build.gradle android-studio-3.0

我最近打开了一个旧项目,将Android Studio更新为3.1.3,现在无法运行该项目。这是我收到的消息:

Unable to find method 'com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector;'.

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. 

在第二次尝试后,此消息随后出现:

Could not initialize class com.android.build.gradle.internal.ide.ModelBuilder

Gradle Project sync failed

gradle项目同步一直失败,我在下面尝试了所有这些解决方案,包括无效/重新启动缓存,删除.gradle文件等。

Unsuccessful solutions

我不是Android的向导,所以如果有人可以带领我朝正确的方向前进,将不胜感激!

1 个答案:

答案 0 :(得分:1)

我怀疑这与番石榴中的冲突有关,具体取决于 您使用的Gradle版本和您的依赖项使用的Guava版本。

Guava 21Guava 20)中添加了toImmutableList函数。

我建议您尝试将项目的gradle版本降级到3.3左右,然后重试。