如何克服 Android Studio 无法解析 android 类的符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24970646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 08:58:53  来源:igfitidea点击:

how to overcome Android Studio cannot resolve symbol for android classes

androidandroid-studio

提问by Idob

I'v just installed Android Studio 0.8.2 for my first time and I have a lot of "Cannot resolve symbol" errors. The errors occur on both new projects and projects which were exported from eclipse.

我第一次安装了 Android Studio 0.8.2,我有很多“无法解析符号”错误。新项目和从 eclipse 导出的项目都会发生错误。

JDK version: jdk1.8.0_11

JDK版本:jdk1.8.0_11

Android studio errors: Android studio errors

Android工作室错误: Android 工作室错误

Project's grade file enter image description here

项目成绩文件 在此处输入图片说明

采纳答案by Akshit Rewari

In the menu bar

在菜单栏中

Select tools>-android>-SDK manager

选择工具>-android>-SDK管理器

and download the SDK build tools, SDK platform and Google API's( the Google API stores packages such as "import android.view.Menu" etc.) for the target SDK version of your project(20 as shown in your screenshot). if you are not sure which items you have to download , you can select all of them.(will take more time to download of course).

并为项目的目标 SDK 版本下载 SDK 构建工具、SDK 平台和 Google API(Google API 存储诸如“import android.view.Menu”之类的包)(屏幕截图中显示的 20 个)。如果您不确定必须下载哪些项目,您可以选择所有项目。(当然下载需要更多时间)。

Restart the IDE

重新启动IDE

回答by Priyanthi

You can do "File" -> "Invalidate Caches...", and select "Invalidate and Restart" option to fix this.

您可以执行“文件”->“使缓存无效...”,然后选择“无效并重新启动”选项来解决此问题。

回答by serv-inc

Android Studio suddenly cannot resolve symbolshelped:

Android Studio 突然无法解析符号帮助:

  • Exit Android Studio
  • Back up your project
  • Delete all the .iml files and the .idea folder
  • Relaunch Android Studio and reimport your project
  • 退出 Android Studio
  • 备份您的项目
  • 删除所有 .iml 文件和 .idea 文件夹
  • 重新启动 Android Studio 并重新导入您的项目

回答by Karegyeya Calvin

I run into the same problem, i solved it by performing a clean project. To do this go to;

我遇到了同样的问题,我通过执行一个干净的项目来解决它。要做到这一点,请前往;

Select build>-clean project>

选择build>-clean project>

回答by Davide

If your library is an androidxone and never worked before, the problem is likely the one described in this other questioninstead.

如果您的图书馆是一个androidx以前从未工作过的图书馆,那么问题很可能是另一个问题中描述的问题

回答by Albert

Delete folder: C:\Users\{your-user}\.AndroidStudio{your-version}\system\caches

删除文件夹:C:\Users\{your-user}\.AndroidStudio{your-version}\system\caches

It helped me

它帮助了我