Android Studio - All file names in project are red

2019-02-01 15:58发布

问题:

I imported a ADT Project in Android Studio. I got a ton of errors, but I could fix them all. I don't think the "how" is important in this case, I wouldn't be able to recall all the errors anyways. The project runs now without errors, but somehow Android Studio marks all files red. Just the filenames, there are no errors in the code. I tried cleaning and restarting.

Did someone experience something like this before? Or maybe a related problem with IntelliJ someone could solve?

Edit:
It was the version control. The project was unversioned but in a SVN controlled folder. Thats what the red was indicating. A solution could be to copy the project to a different folder or to add the files to version control.

回答1:

Perhaps you are seeing the File Status colors that Android Studio uses to show the status of the file. Open Settings and go to Editor > Colors & Fonts > File Status. Here you can see what all of the different colors mean. My guess is that your reddish files are that color because you have not yet added them to source control.



回答2:

I had the same problem: everything was in red and my MainActivity was not found. I resolve it by doing:

File -> Invalidate Cashes / Restart

Et voilà!!

Good luck



回答3:

If anyone happens to import a project and then all files and folder names are brown, that means files/folders are unknown. This happens if imported project has VCS control, to solve this you just have to check in your project root folder for .idea folder and inside it if there's an XML file called vcs.xml: if so, just rename it or delete it, then close and reopen project, all names will become black.



回答4:

It can be because of you version control system. May be you haven't committed your change on the files committing your change will restore the file names' color to white or go to File->Settings->Version Control and disable the VCS



回答5:

From the screenshot that you have attached, it appears that it is because of VCS enabled.

Case 1: You want to use VCS. And you have not committed the code. If this is the case, then please commit the code.

Case 2: VCS is enabled and you are not aware of that. To disable this, Go to Setting-> Version Control.

In the right panel, you will see a Project and type of VCS. Select that row and click on the VCS item. In the dropdown, select .

This will resolve your issue.



回答6:

Using SVN repository under Android Studio, I got same issue after renaming the package name. To solve it, you will need to do a right click on the red files/Subversion/Add to CVS -> Then the files will be green, after you have to commit them, they will be normal (black color).



回答7:

It is because Version Control(like Git) have been enable in your project.

Go to File -> Settings -> Editor. Under Version Control select File Status Colors. It contains list of different colors and what they mean.



回答8:

This happened to me every time I would set up a git repo in my project. To answer the question, simply add the problematic files to your VCS, "git add" in my case and you should be good to go.



回答9:

I've had similar problems with IntelliJ and have some more details that may prove helpful:

  • If for some reason IntelliJ imports a project using a VCS other than what is used by your project, it may effect how it looks at project roots. For example, IntelliJ kept importing projects with Subversion as the VCS when we use Git -- Subversion creates a root for every top-level folder and Git just had just a single root (I have no idea why).
  • As suggested above, going into Settings->Version Control (IntelliJ IDEA ->Preferences for OS X) and changing the VCS type to "Git" or "none" would make the red characters go away.
  • I had no idea why IntelliJ kept importing the project as Subversion so I went into the plugins and disabled "Subversion Integration" -- that got rid of the problem for good.


回答10:

Solutions for existing project that are newly cloned

  • delete or rename .idea/vcs.xml and restart android studio
  • Check exact folder is added as root in File->Settings->Version Control
  • Check proper vcs tool configured in File->Settings->Version Control and remove unwanted entries


回答11:

I went to my project folder (c:\users\ ... \AndroidStudioProjects\my project folder\ , and deleted the .git folder. (it's hidden).

The Problem Solved.