file was loaded in the wrong encoding: 'UTF-8' in android studio

随声附和 提交于 2019-11-30 22:57:11

For people in future:

I had the same problem.

I was able to solve it simply by making a copy of the project and opened the copied project. Copied project worked perfectly fine.

Note: I got this problem because of improper shutdown of my PC.

In my case it happend after Windows died with the blue screen, here's how I fixed it:

  1. Close Android Studio
  2. Find a directory named .AndroidStudioX.X in C:Users/YourUsername and rename it to old.AndroidStudioX.X
  3. Restart Android Studio and choose the renamed old.AndroidStudioX.X to import settings from.

My answer is taken from here https://stackoverflow.com/a/53476487/4277741

That's not an encoding issue. That's compiled bytecode, the content of a .class file. You cannot simply rename it into .java and expect it to work.

This is an old issue, but if anyone comes across this, what isn't mentioned above, but happening for me is that the original file on disk is intact java code. Android Studio is reading it like this for some reason.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!