问题
In Android Studio 3.1.2 I am suddenly getting the following message in a yellow tape frame at the top of my editor:
No IDEA annotations attached to the JDK 1.8 (C:\Program Files\Android\Android Studio\jre), some issues will not be found
I also have a warning in Edit Configurations:
Default Activity not found
How can I solve these issues?
回答1:
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.
回答2:
I have been working on 3.2.1 version since October 2018 (for 1 month).
But today I started my project in AndroidStudio with a many errors.
I tried to Invalidate Caches and Restart
. But it doesn’t helped me.
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
.
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).
Then I restarted AndroidStudio, and I chose “Do not import settings”. Like this:
This method worked for me.
回答3:
Go to File -> Invalidate Caches / Restart... -> Invalidate Caches and Restart
回答4:
I am also stuck with this same issue since last week on 3.2.1 version.
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.
While launching I selected to import settings from the last version and proceed. it will reconfigure all the settings.
Try that.
回答5:
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
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.
回答6:
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.
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.
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.
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.
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.
回答7:
I just found the solution. Follow the path:
File -> Invalidate Caches / Restart...
回答8:
Remove caches folder from C:\Users\username\ .AndroidStudio3.3\system and re import project worked for me.
回答9:
My answer might come late, but here is what fixed the issue for me:
Turn off Android studio
Open
C:\Users\UserName\.android
and rename thebuild-cache
folder tobuild-cache.bak
Open
C:\Users\UserName.AndroidStudio3.2\system
. Rename the files:caches
—>caches.bak
compiler
—>compiler.bak
compile-server
—>compile-server.bak
conversion
—>conversion.bak
external_build_system
—>external_build_system.bak
frameworks
—>frameworks.bak
gradle
—>gradle.bak
resource_folder_cache
—>resource_folder_cache.bak
Restart Android Studio; it will generate those folders again.
After the success, delete the
.bak
files.
回答10:
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.
回答11:
The following steps resolved the error for me,
Step 1: Search everywhere (shift + shift), then type "Setup JDK" as search text
Step 2 : Select something from the list (I selected the highlighted one),
That's it, you shouldn't be seeing the error now.
回答12:
The new Android Studio update is available, version 3.3 and that solved my problem. Happy coding.
来源:https://stackoverflow.com/questions/50740240/no-idea-annotations-attached-to-the-jdk-1-8-c-some-issues-will-not-be-fo