Android Studio 3.1:编辑器中错误的未解析引用 [英] Android Studio 3.1: Erroneous unresolved references in editor
问题描述
我正在运行 Ubuntu 17.10,并且我刚刚将 Android Studio 从版本 3.0.1 更新到了 3.1.这是帮助中的版本信息 ->关于:
I'm running Ubuntu 17.10, and I've just updated Android Studio from version 3.0.1 to 3.1. Here's the version information in Help -> About:
Android Studio 3.1
Build #AI-173.4670197, built on March 22, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.13.0-37-generic
不幸的是,虽然 IDE 能够在我(有史以来的第一个)Kotlin 项目中解析特定于 android 的引用,但在新版本中似乎无法解析.这是一个屏幕截图,显示了我的意思:
Unfortunately, while the IDE was able to resolve android-specific references before in my (first ever) Kotlin project, in the new version it appears unable to. Here's a screenshot showing what I mean:
在 Android Studio 3.1 中,它声称诸如 setContentView()
之类的核心 Android 函数不存在,并不断提示我为它创建一个抽象函数 -我显然不想这样做.但是,如果我点击构建按钮,我会得到 BUILD SUCCESSFUL in 8s
.
In Android Studio 3.1, it's claiming that core Android functions such as setContentView()
don't exist, and keeps prompting me to create an abstract function for it - which I clearly don't want to do. However, if I hit the build button, I get a BUILD SUCCESSFUL in 8s
.
为什么我的编辑器会这样做,以及如何让与 Android 相关的函数和类再次正确解析?
Why is my editor doing this, and how I get get Android-related functions and classes to resolve correctly again?
- 构建 → 清理然后构建 → 重建没有帮助.
- 文件 → 使缓存无效并重新启动也无济于事
- 手动 Gradle 同步也不行.
- 使用 Java 而不是 Kotlin 编写的另一个项目运行良好.
- 链接到我遇到问题的项目(已打开- 来源)
- Build → Clean and then Build → Rebuild doesn't help.
- File → Invalidate Caches and Restart doesn't help either
- Neither does a manual Gradle sync.
- A different project that's written in Java instead of Kotlin works fine.
- Link to the project I'm experiencing issues with (it's open-source)
推荐答案
- 退出工作室.
- 删除 .idea/(在我看来这是最重要的)、build/、app/build 目录.
- 启动工作室
- 设置设置 -> 构建 -> Gradle 设置返回(在我的例子中是最后一个稳定的 Gradle 本地发行版).
- 清理并重建项目.
帮助我.
这篇关于Android Studio 3.1:编辑器中错误的未解析引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!