Android Java source java files opens as png files

2020-04-15 21:02发布

Today Android Studio started to behave strange. Source java files opens as png files something. I can build and run the app and if I look in the file system the java files looks ok. I do Invalidate cache and restart, I delete .idea and build folders but no change. The strange thing is I can debug run the app. If I want to change java files I have to open like Notepad and save then build project again

There must be some file/setting in Android studio that control this. I delete the project ide and build folded but no change, where in Android Studio can I reset this to start working normal? enter image description here

2条回答
太酷不给撩
2楼-- · 2020-04-15 21:05

When you save a file at notepad and open it in Android Studio, it will happen because notepad use a different encoding (ANSI).

You can set your project file encodings at Settings->Editor->File Encodings

enter image description here

You can also edit a unique file encoding at File->File Encoding

Make sure your project file encoding is UTF-8 (default)

enter image description here

Another important setting is File Types that you can take a look too. Here is mine .java file setting to you as example.

enter image description here

查看更多
家丑人穷心不美
3楼-- · 2020-04-15 21:23

I found a solution that worked for me. I hade to open every java source file and all xml files into a text editor(Notepad++) and change something then save the file back to origin.

Now Android Studio detect all files as normal

查看更多
登录 后发表回答