How to fix Android Studio bug not showing .xml files properly? - android

Due to some reason, my Android Studio has stopped showing .xml files properly. Here's an example of what I get:
I have checked my .xml files by opening the folder using Windows Explorer and opening the files in WordPad. They are all perfectly okay. It's just that Android Studio is displaying in my .xml files what just seems nonsense to me. (By the way, some .xml files are being properly displayed in Android Studio).
Can anyone please help me out?

I figured out how to solve this problem.
Make a backup of your app folder.
Open your layout folder (right-click on any .xml file and click 'Show in Explorer'). Close Android Studio. Move (cut) all except one of the files to your desktop (or any other folder). Restart Android Studio. After the gradle sync has finished, move (cut) all the files back to the layout folder. Repeat for the last file.
Do the same if there is a similar problem with your java files.

Related

Android Studio not completing xml tags

So I found another question like mine but the answers didn't solve my problem. Yesterday I updated to 3.5.0 Android studio and the xml tag auto completion is not working anymore. Example: I type Textview -and it adds automatically the basic attributes, like width and height, but the closing tag is missing. And it really slows me down.
Your cache has been corrupted. To resolve issue try following:
Close Android studio completely.
Take backup of following folders & then delete it (I.e. move to any other safe place. find it in your system, most probably in C: drive if using Windows)
<user>\.gradle\caches
<user>\.AndroidStudio{your_version}\system\caches
Now start Android Studio again. It should take time to re-build cache but now it would be working fine.
Try deleting .idea folder and all .iml files from the project, restarting Android Studio and rebuilding gradle did the trick. Autocomplete in XML support library is working again.
Checking out files from Version Control or copying all the source files in a new project would do the trick as well.

Android Studio Issue: Loads incorrect content in many files

When I create a new project, many files are being generated incomplete
like colors.xml, mipmap files and many more.
Already tried the following:-
Invalidate cache and restart.
Deleted temp files from my PC.
Uninstalled Android Studio and reinstalled it but after some time the
same problem occurred again.
I am attaching Images to some files which are incomplete
Please give some suggestions or anyone else who had the same problem can help me out.
Follow these steps:-
Close the Android Studio.
Go to:
C:\users\your_user_name\.AndroidStudio3.4\system\caches
Delete the caches folder.
Go to:
C:\Users\your_user_name\.gradle\caches
Delete this caches folder also.
Now you can start your Android Studio and start working.
Your Problem will be solved.
I had a similar problem. some of the layout xml files are displayed with odd characters in android studio. The studio does not show them in xml format. These files are fine outside the studio and open well with notepad or any browser.
I deleted the caches as stated above and everything is fine. Android studio is showing up the files correctly.

Some Files Got Corrupted

The power went down and on restart all files are showing these weird characters and message is saying about I am using wrong encoding.
The interesting thing is, the code is appearing like this only in Android Studio. If I open any of individual file with notepad, the code is just fine.
Actually, I got into the same problem To fix this issue
First, try Invalidate caches and restart if it not works then delete .gradle .idea folders in the project directory and open the project again.
Note: Take Backup of project folder before trying

How to Index files on android studio

TLDR; Is there a keyboard shortcut or a command to index the whole project in android studio
I noticed some drawable resources were still unresolved when I copied them in the res/drawable folder in android studio.
I did a File > Sync with File System thinking that would resolve the issue.
But it didn't solve it as they were still unresolved.
The build is successful and the app runs but the IDE is not happy for some reason.
It works when I restart android studio but I don't want to restart it every time I add an asset.
As android studio indexes the files sometimes saying 'indexing files' at the bottom. So I searched for it and there doesn't seem to be a keyboard shortcut.
Another issue:
The image assets get added as filename (v24). Why is that?

Files in Android Studio don't match files in file explorer

I have run into this in a few different projects in Android Studio recently. I will launch AS, open a project and some files and see that they are completely wrong. Viewing the same files in another text editor shows the correct text. As you can see in this image, the files as seen in Android Studio are usually made of text from the Android SDK or similar.
I have tried invalidating the cache and synchronizing the files individually and on the project level. The only thing that I have found works is copying the text from another editor into Android Studio.
I would think it may be a virus on windows, but so far, I have only ever seen this in Android Studio.
Any help would be nice thank you.

Categories

Resources