【问题标题】:Android studio codes are showing red color. But it runs successfullyAndroid Studio 代码显示为红色。但它运行成功
【发布时间】:2020-02-27 05:31:48
【问题描述】:

我项目中的所有代码都是红色的。但我可以成功运行我的项目。我更新了安卓 工作室以及我清理,重建项目。错误仍然存​​在。谁能帮忙 解决这个问题。

【问题讨论】:

  • 只是尝试重新同步 gradle,如果不起作用,则使缓存无效并重新启动。
  • Open File menu > Invalidate Caches / Restart.. 选项并点击 Invalidate and Restart。
  • 只需删除 .gradle 目录并重建项目,如果没有解决,然后转到文件菜单 > 使缓存无效/重新启动
  • @ShahnawazKhan 我做到了。但仍然存在错误

标签: android android-studio kotlin ide


【解决方案1】:

解决方案 1:

尝试同步 gradle

File -> Sync Project With gradle Files 

如果不起作用,请按照解决方案 2。

解决方案 2:

只需删除 dependencies{} 部分中的依赖项并同步

然后返回所有依赖项并同步

第 1 步

//1. Remove all dependencies 
//2. Sync
dependencies {

}

第 2 步

//1. back to all dependencies (Re-Add) 
//2. Sync
dependencies {
   implementation fileTree(include: ['*.jar'], dir: 'libs')
   ......
   ......
}

有一天我遇到了同样的问题,我用第二招解决了它们..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 2011-11-26
    相关资源
    最近更新 更多