【问题标题】:Android Studio: Gradle's dependency cache may be corruptAndroid Studio:Gradle 的依赖缓存可能已损坏
【发布时间】:2021-08-09 16:26:51
【问题描述】:

我正在尝试为 Android Studio 关注 this YouTube tutorial,但是当我创建我的项目时,我收到以下错误:

class org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager cannot be cast to class org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager (org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @1824eb4b; org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @61548dd0)
class org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager cannot be cast to class org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager (org.jetbrains.kotlin.idea.core.script.configuration.CompositeScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @1824eb4b; org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @61548dd0)

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.
  • AS:2020.3.1(从 4.3 重命名的版本)
  • 操作系统:Linux (Fedora)
  • Gradle:6.8

起初,它似乎与this issue 非常相似,但我的错误的前两行不同,可能是因为我的AS版本更新了很多。

我很肯定这与网络超时无关。

我尝试了类似问题的解决方案,从~/.gradle/wrapper/dists 中删除我的Gradle 包装器,然后重新同步项目。虽然这消除了错误,但它无法使用初始项目文件生成 app 目录,我只剩下配置文件:

因此,我要么正在寻找针对 dependency cache 错误的不同解决方案,要么正在寻找缺失项目文件的修复方法。

此问题似乎特定于 AS 2020.3.1 中使用 Kotlin 的项目。我无法使用 Java 项目或 AS 4.1.2(本教程中使用的版本)进行复制。

更新:删除并重新安装 AS 2020.3.1 并不能解决问题,但将 AS 2020.3.1 替换为 AS 4.1.2 可以。此外,在将 2020.3.1 替换为 4.1.2 并重新安装 2020.3.1 后,该项目随后在 2020.3.1 上运行。这一定是由于 2020.3.1 的配置问题,该问题已通过先前版本的配置设置修复。

【问题讨论】:

    标签: android-studio kotlin gradle jetbrains-ide


    【解决方案1】:

    这是一个没有太多解释的老生常谈的答案,但经过很多麻烦,以下解决方案产生了一个有效的项目。

    该问题似乎是由 2020.3.1 的配置问题引起的,通过打开之前版本的 Android Studio 时发生的自动配置已解决。

    1. 删除Android Studio(我的install_dir是/usr/local):
    rm -rf {install_dir}/android_studio
    
    1. download archive下载Android Studio 4.1.2
    2. 安装并运行 Android Studio 4.1.2
    tar -xvzf android-studio-ide-201.7042882-linux.tar.gz
    cd android-studio/bin
    ./studio.sh
    

    注意:如果 AS 运行失败,remove disabled_plugins.txt

    1. 关闭 Android Studio
    2. 重新下载(如有必要)AS 2020.3.1
    3. 安装并运行 AS 2020.3.1
    tar -xvzf android-studio-2020.3.1.22-linux.tar.gz
    cd android-studio/bin
    ./studio.sh
    

    注意:同样在这里,如果 AS 无法运行,请删除 disabled_plugins.txt

    1. 创建一个Empty Activity Kotlin 项目,应该没有问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-04
      • 2017-07-25
      • 1970-01-01
      • 2016-10-27
      • 1970-01-01
      • 2023-03-20
      • 2017-07-27
      • 2016-11-21
      相关资源
      最近更新 更多