2

Please look at snapshot of the opened file below.

When I double click on MyUtils.java it is showing this XML format:

when I double click on MyUtils.java it is showing this xml format

But when I open it manually from Windows Explorer it already have correct Java code inside:

file is having non-corrupted code inside

I have tried these but the problem remains:

  • clean, rebuild project
  • invalidate cache and restart
  • deleted .gradle and .idea auto generated folders from the project
  • updated and restart Studio.
LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • Try to delete all the IDE folders to start with the defaults: https://intellij-support.jetbrains.com/hc/articles/206544519. – CrazyCoder Oct 12 '18 at 19:41

3 Answers3

1

It happens because of wrong File Encoding and you can see my answer about it in here.

Solution: The solution will be reinstalling Android Studio or, go to:

File -> Other Settings -> Default Settings, find File Encodings, change Project Encoding to System-Default or UTF-8 format.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • Thanks, your solution is good n impressive but it is not working for me, i have tried with changing default and rest all encoding also tried Sync Project with Gradle Files like #shahab yousfi said on above answer., but problem is reaming same. Now i am tried to reinstalling Android studio. – Chandra dev Kumawat Oct 13 '18 at 06:48
  • Reinstalling or updating will help and solve the issue since I've had the same issue too. – ʍѳђઽ૯ท Oct 13 '18 at 06:49
  • 1
    Thanks, fresh installing of studio solved the problem. I have to make it completed uninstall from system like removing .android, .AndroidStudio ,.gradle JetBrains directory appdata from appdata. And selecting "do not import setting" for first time popup of studio solveed my problem. Thanks again for saving my day. ( please let me know the correct reason why this happen if you found any reason) – Chandra dev Kumawat Oct 13 '18 at 09:58
  • 1
    Well sure. If you don’t import the old config, it will be fine. I believe this was an issue with the IDE and I suppose it will be fixed in the new updates since many users had the same issue too. Glad to hear it’s working now. Happy coding – ʍѳђઽ૯ท Oct 13 '18 at 10:05
0
  • try 'Sync Project with Gradle Files'. you can find it in top-left in 'File' tab or click on button at the left of 'Avd Manager' button.

  • go to Project mode and right click on the root folder of your project and Synchronize it

codegames
  • 1,651
  • 18
  • 16
0

Actually you do not need to reinstall the Android Studio.

I met with the similar problem. The way to fix it is if you are using MAC OS then goto

'Android Studio->Preferences->Editor->File Types'

then check the Recognized File Types and look for your bug file in Registered Patterns and remove it.

Then all be good.

Jeffrey
  • 71
  • 4