Java JDK 1.8 (C:\...) 没有附上IDEA注解,有些问题不会被发现
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50740240/
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
No IDEA annotations attached to the JDK 1.8 (C:\...), some issues will not be found
提问by Morteza Baghalpoor
In Android Studio 3.1.2 I am suddenly getting the following message in a yellow tape frame at the top of my editor:
在 Android Studio 3.1.2 中,我突然在编辑器顶部的黄色磁带框中收到以下消息:
No IDEA annotations attached to the JDK 1.8 (C:\Program Files\Android\Android Studio\jre), some issues will not be found
JDK 1.8 (C:\Program Files\Android\Android Studio\jre) 无IDEA注解,部分问题不会被发现
I also have a warning in Edit Configurations:
我在编辑配置中也有警告:
Default Activity not found
未找到默认活动
How can I solve these issues?
我该如何解决这些问题?
回答by Morteza Baghalpoor
I just found the solution. Follow the path:
我刚刚找到了解决方案。按照路径:
File -> Invalidate Caches / Restart...
回答by Joe Flack
For me, clicking "Attach Annotations" at the top right of the yellow notification bar helped.
对我来说,单击黄色通知栏右上角的“附加注释”有帮助。
This following resource helped as well: https://www.jetbrains.com/help/idea/annotating-source-code.html
以下资源也有帮助:https: //www.jetbrains.com/help/idea/annotating-source-code.html
But be wary:
但要小心:
The annotations artifact requires JDK 1.8 or higher. If your project is compiled using JDK 1.5, 1.6 or 1.7, use the annotations-java5 artifact instead.
注释工件需要 JDK 1.8 或更高版本。如果您的项目是使用 JDK 1.5、1.6 或 1.7 编译的,请改用 annotations-java5 工件。
回答by Hamza Rahman
Go to File -> Invalidate Caches / Restart... -> Invalidate Caches and Restart
去 File -> Invalidate Caches / Restart... -> Invalidate Caches and Restart
回答by Levi Rizki Saputra
Solution
解决方案
- Close Android Studio
- Go to
C:\Users\UserName\.android
and rename thebuild-cache
folder tobuild-cache.bak
Go to
C:\Users\UserName\.AndroidStudio3.2\system
and rename these folderscaches
tocaches.bak
compile-server
tocompile-server.bak
compiler
tocompiler.bak
conversion
toconversion.bak
external_build_system
toexternal_build_system.bak
frameworks
toframeworks.bak
gradle
togradle.bak
resource_folder_cache
toresource_folder_cache.bak
Open the Android Studio and open your project again.
- 关闭 Android Studio
- 转到
C:\Users\UserName\.android
并将build-cache
文件夹重命名为build-cache.bak
转到
C:\Users\UserName\.AndroidStudio3.2\system
并重命名这些文件夹caches
到caches.bak
compile-server
到compile-server.bak
compiler
到compiler.bak
conversion
到conversion.bak
external_build_system
到external_build_system.bak
frameworks
到frameworks.bak
gradle
到gradle.bak
resource_folder_cache
到resource_folder_cache.bak
打开 Android Studio 并再次打开您的项目。
回答by ? ??? ?
Both errors mentioned in the question also showed up on my computer. This worked for me:
问题中提到的两个错误也出现在我的电脑上。这对我有用:
- Remove and re-install Android Studio
- During the installation, when asked to keep Android Studio settings, do not keep the settings
- Do not open your project from disk; re-import your project from Version Control System, for example GitHub.
- 删除并重新安装 Android Studio
- 在安装过程中,当要求保留 Android Studio 设置时,不要保留设置
- 不要从磁盘打开你的项目;从版本控制系统重新导入您的项目,例如 GitHub。
回答by Seeker
I am also stuck with this same issue since last week on 3.2.1 version.
自上周 3.2.1 版本以来,我也遇到了同样的问题。
What worked for me is to remove (or you can move it as a backup) the ".AndroidStudio3.2" (for you it will be .AndroidStudio3.1) folder located in "C:\Users{username}\" and then reopen the Android Studio.
对我有用的是删除(或者您可以将其作为备份移动)位于“C:\Users{username}\”中的“.AndroidStudio3.2”(对您来说它将是 .AndroidStudio3.1)文件夹,然后重新打开 Android Studio。
While launching I selected to import settings from the last version and proceed. it will reconfigure all the settings.
启动时,我选择从上一版本导入设置并继续。它将重新配置所有设置。
Try that.
试试那个。
回答by Tom Rutchik
I'm going to share some information I just discovered about Invalidate Cache / Restart, and I think it's strongly related to the 3.2.1 release. This may explain why it works for some people and why it doesn't work for others. I discovered this problem regarding a different situation, but I think it might be relevant to this problem, so it may be worthwhile giving it a try.
我将分享一些我刚刚发现的关于无效缓存/重启的信息,我认为它与 3.2.1 版本密切相关。这可以解释为什么它对某些人有效而为什么它对其他人无效。我在不同的情况下发现了这个问题,但我认为它可能与这个问题有关,因此值得一试。
There are times when the Invalidate Cache / Restart won't clear the cache for an opened project. I'm not sure what gets you into that state, but that happened to me. What I did to correct the problem was to rename the project directory name, open Android Studio with the new renamed name, then run Invalidate Cache / Restart. I then closed the project, renamed the project directory name back to it's original name and then opened Android Studio using the original name and that fixed my problem.
有时,无效缓存/重新启动不会清除已打开项目的缓存。我不确定是什么让你进入那种状态,但这发生在我身上。我为纠正问题所做的是重命名项目目录名称,使用新重命名的名称打开 Android Studio,然后运行 Invalidate Cache / Restart。然后我关闭了项目,将项目目录名称重命名为其原始名称,然后使用原始名称打开 Android Studio 并解决了我的问题。
In my situation, the problem I was having was that Android Studio was improperly displaying the contents of a file, but when I examined the file using an external viewer, the file actually had the correct content. So, my guess was that, Invalidate Cache / Restart would fix the problem. But it didn't work until I did the little trick I mentioned above. So that's why I sharing my discovery, since it might explain why Invalidate Cache / Restart works for some people and not others. Again, I don't yet have a clue on how a project gets into the state where it where it won't Invalidate Cache for an open project. Possible and file lock issue, or some background executor task responsible for clearing the cache for the opened project doesn't get run before Android Studio restarts.
在我的情况下,我遇到的问题是 Android Studio 未正确显示文件的内容,但是当我使用外部查看器检查文件时,该文件实际上具有正确的内容。所以,我的猜测是,无效缓存/重启会解决这个问题。但是直到我做了我上面提到的小技巧之后它才起作用。所以这就是我分享我的发现的原因,因为它可能解释了为什么无效缓存/重启适用于某些人而不是其他人。同样,我还不知道项目如何进入它不会使打开的项目的缓存失效的状态。可能的文件锁定问题,或者某些负责清除打开项目缓存的后台执行程序任务在 Android Studio 重新启动之前没有运行。
Update: I actually had the exact same problem occur in one of my projects. Invalidate Cache / Restart did not work until I need my little trick of renaming the project, opening it, Invalidate Cache / Restart, close project, rename project back to original name, an opening it. The message No IDEA annotations attached to the JDK 1.8 was then gone.
更新:我的一个项目中实际上发生了完全相同的问题。使缓存/重启无效,直到我需要重命名项目的小技巧,打开它,使缓存/重启无效,关闭项目,将项目重命名回原始名称,然后打开它。消息 No IDEA annotations附加到 JDK 1.8 然后消失了。
One of the things I tried that didn't work, was to close the project that had the problem and run Invalidate Cache / Restart from a different project. So it's not quite accurate to say the Invalidate Cache / Restart sometimes doesn't work for opened projects. I have reported the problem to the android group through the "Submit Feedback" channel. They should be able to figure out what the internal code issue is. It would be useful to find my post to that team and add that you're experiencing the same problem.
我尝试过但不起作用的一件事是关闭有问题的项目并从不同的项目运行无效缓存/重新启动。所以说无效缓存/重启有时对打开的项目不起作用是不太准确的。我已经通过“提交反馈”渠道向android组报告了该问题。他们应该能够弄清楚内部代码问题是什么。找到我发给该团队的帖子并补充说您遇到了同样的问题会很有用。
回答by V.March
I have been working on 3.2.1version since October 2018 (for 1 month).
But today I started my project in AndroidStudio with a many errors.
自 2018 年 10 月(1 个月)以来,我一直在研究3.2.1版本。
但是今天我在 AndroidStudio 中开始了我的项目,但出现了很多错误。
I tried to Invalidate Caches and Restart
. But it doesn't helped me.
我试过了Invalidate Caches and Restart
。但这对我没有帮助。
So, I opened the folder C:\Users\{username}
.
There I found three folders: one for the real version - .AndroidStudio3.2
and two for older versions - .AndroidStudio3.1
and .AndroidStudio2.3
.
于是,我打开了文件夹C:\Users\{username}
。
在那里我找到了三个文件夹:一个用于真实版本 -.AndroidStudio3.2
两个用于旧版本 -.AndroidStudio3.1
和.AndroidStudio2.3
.
I could only delete the folder with the actual version, but I deleted all the folders. (Because I have no important user settings in AndroidStudio).
我只能删除带有实际版本的文件夹,但我删除了所有文件夹。(因为我在 AndroidStudio 中没有重要的用户设置)。
Then I restarted AndroidStudio, and I chose “Do not import settings”. Like this:
然后我重新启动AndroidStudio,并选择“不导入设置”。像这样:
This method worked for me.
这种方法对我有用。
回答by Hlompho Mohapi
The new Android Studio update is available, version 3.3 and that solved my problem. Happy coding.
新的 Android Studio 更新可用,版本 3.3 解决了我的问题。快乐编码。
回答by Nik
Remove cachesfolder from C:\Users\username\ .AndroidStudio3.3\system and re import project worked for me.
从 C:\Users\username\ .AndroidStudio3.3\system 中删除缓存文件夹并重新导入对我有用的项目。