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
Related
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.
I have a javascript file (ParameterFunctions.js) which isn't making it to the device for some reason.
It's definitely in the project:
I extracted the apk and it's definitely inside of it:
When I look at the files on the device is doesn't exist:
Why is this happening and how do I fix it? I've tried:
Invalidate caches and restart
Uninstall and reinstalled
Sync project with file system
Sync project with gradle files
Reboot the device (both before and after reinstalling)
I figured it out. There was a syntax error in the js file I was trying to include. Rather than report it Android decided that the entire file shouldn't be recognized.
Ever since i upgraded to android studio 3.4 and going forth to 3.5.3 and i been experiencing projects that i used to work on earlier in the day suddenly fail to load and modules can't be read and opening any files .xml , .gradle all i see is the something like below:
I tried :
resetting the encoding to UTF8 from android studio settings > editor
invalidating the cache and restart
delete the .idea folder and reloading project
Nothing works, unless i have a copy of the same project or have it on Github and clone it again and re open it.
Note:
while the files look like the image you see in android studio, opening any of them in an editor like VScode shows the correct contents of the file
Anyone have a clue, because this is really frustrating
TL;DR
disable Dart and flutter plugins in File > settings > plugins menu,
reopen your project like you usually do.
Extra steps that could help:
clear cache
delete the .idea folder
delete all .iml files from you project as suggested by #Max Shwed
How i got there:
The issue mentioned above kept happening in a number of android projects old and new.
before uninstalling AS an reinstall i thought i give it one last try, i cleared the cache, delted all the the .iml files manually along with the .idea folder.
After that i imported the project and let AS regenerate the deleted files, one weird thing happened is that my build.gralde file was looking totally different there was Dart code inside it and package import from dart, while the file was completely unaltered when opened in any text editor (thankfully AS didn't re-write the file) it was simply built differently in AS view.
Suspecting Dart plugin to be the problem since i have some demo Flutter apps i been working on , i disabled the Dart plugin and just re-opened my project and Voila everything looks fine and project built successfully and run.
i think it's flutter framework issue
but i have a solution that i tried and fixed this
just make right click in your distributed file -> local history -> show history -> and revert one step
it will get your original code without any formatting
and wait for the next flutter plugins to update
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.
my project was working well but suddenly when I ran it on my phone, Android Studio freezes and I should stop it from task manager.
before this happens I installed "Geny motion" & "Virtual Box", but when the error occurred I uninstalled them. but the problem insisted.
Solutions I've tried
I uninstalled it and installed it again
I unplugged and plugged in my device
I disabled android indexing from setting
None of the above solutions worked.
I had today this exact problem. None of the above helped me until I found simple solution here
Just run File -> Invalidate Cache and Restart
That simple and it works!!!
Delete all Android Studio data - .gradle .android .androidstudio folders from your home folder. And all project build folders gradle and iml files.
This worked for me.
1.Close the project
2.Remove the project
3.Close Android Studio
4.Open it again
5.Open the project
Enjoy Coding!
I checked my java file and I saw somehow all the code in one of my java files was replaced with "NULL NULL NULL NULL....."
I deleted the file and the application runs without a problem.
Android Studio (3.1.3) froze on me while editing a source file. I waited and finally killed the process in Task Manager (Windows). Twice I tried to start up again and both times it got stuck with the "indexing..." message in the lower right. Both times I ended the process in Task Manager.
I looked in the source folder of the project I was working on. The source file I had been editing when it froze was "Receipt.java". There was another file in the src folder "Receipt.java__jb_tmp__". I deleted that file and Android Studio started up fine. It looks like I lost some edits, though.
When I did start up, it detected there had been some error and offered to submit a report.
If the project is large & has a lot of modules, you might need to increase the Allocated Heap Size for Android Studio.
Go to Edit Custom VM Options from Help menu and increase the value for -Xms and -Xmx
This is what I'm using
-Xms2048m
-Xmx8192m
-XX:MaxPermSize=2048m
-XX:ReservedCodeCacheSize=1024m
-XX:+UseCompressedOops
In my case color was declared as invalid, Android Studio ignored that and during building it froze. I had to remove the file, let it index, paste it back and fix the color string (it gave me error when I entered the pasted file)
just rename project folder then open IDE, it will show
now rename back to origin folder name, click open project
it work on my case
I have older project with sdk version 22, when I open it in android studio 3.1.2 on macOS. It keep indexing forever, everything was installed and configured properly but indexing loop never stopped.
Following worked for me
File > Invalidate caches/restart… > Invalidate caches/restart
Go to the File menu and click the option Invalidate Caches / Restart This will solve the problem ! Enjoy ;)