Android Studio 3.1:编辑器中未解决的错误引用 [英] Android Studio 3.1: Erroneous unresolved references in editor

查看:149
本文介绍了Android Studio 3.1:编辑器中未解决的错误引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行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相关的函数和类以再次正确解析吗?

Does anyone know why my editor is doing this, and how I get get Android-related functions and classes to resolve correctly again?

更新:我现在有关于此问题的更多信息,但仍未解决:

Update: I've got more information on the issue now, but it's still not resolved:

  • 构建->清理,然后构建->重建无济于事.
  • 文件->使缓存无效,然后重新启动也无济于事
  • 手动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)

推荐答案

  1. 退出Studio.
  2. 删除.idea/(在我看来,这是最重要的),build/,app/build目录.
  3. 开始Studio
  4. 设置设置->构建-> Gradle设置返回(在我的情况下,最后一个稳定的Gradle本地分发).
  5. 清洁和重建项目.

帮助我.

这篇关于Android Studio 3.1:编辑器中未解决的错误引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆