问题
Please look at snapshot of the opened file below.
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:
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.
回答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.
回答2:
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
回答3:
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.
来源:https://stackoverflow.com/questions/52781040/android-studio-file-mapping-problem-not-recognize-files