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

前端 未结 9 1437
挽巷
挽巷 2020-12-09 10:55

my android studio gone crazy like this please help??

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

相关标签:
9条回答
  • 2020-12-09 11:22

    An encoding issue can be solved by deleting all files contained in the Android Studio "caches" folder, which can be found in "C:\Users<username>.AndroidStudioX.Y\system\caches".

    Make sure that to close Android Studio before deleting.

    0 讨论(0)
  • 2020-12-09 11:22

    All you need is to remove the Android Studio settings directory, which can be found:

    on Windows

    C:/Users/yourusername/.AndroidStudioX.Y
    

    on Linux:

    /home/yourusername/.AndroidStudioX.Y
    

    Close Android Studio, delete the directory, then reopen Android-Studio and open your project.

    Also if it happens on a different IDE, it is the same approach.

    If the issue persists, try to copy the content of your project directory into a new directory, then open the project from the new directory.

    0 讨论(0)
  • 2020-12-09 11:24

    I had the same problem and how I fixed it is that I just went to the directory where the java files for my project are located, which in my case is users/user name/AndroidStudioProjects/Project name/app/src/main/java/com/example/android/project name, and here you will find all java codes you wrote for your project just open the one making the problem with notepad and you will find your code here in the right format and perfect just copy all of it and get back to Android Studio window and delete the wrong formatted code and paste this one and wait for it to sync and that's it. If you face the same issue with XML codes just do the same thing find the directory where XML files are located.

    0 讨论(0)
  • 2020-12-09 11:26

    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.

    0 讨论(0)
  • 2020-12-09 11:36

    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.

    0 讨论(0)
  • 2020-12-09 11:44

    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

    0 讨论(0)
提交回复
热议问题