Android Studio - All file names in project are red

2019-02-01 15:55发布

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.

enter image description here

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.

11条回答
Viruses.
2楼-- · 2019-02-01 16:29

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.
查看更多
爷、活的狠高调
3楼-- · 2019-02-01 16:31

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

查看更多
叛逆
4楼-- · 2019-02-01 16:31

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
查看更多
混吃等死
5楼-- · 2019-02-01 16:32

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

查看更多
地球回转人心会变
6楼-- · 2019-02-01 16:32

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).

查看更多
登录 后发表回答