How to Index files on android studio - android

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?

Related

Flutter project, some filenames not identified as .dart files in Android Studio

Picture of problem
I already tried to modify the type analysis of android studio, restarted and recreated the project.
I reinstalled Android Studio and tried different Flutter SDKs and Android Studio versions, but I cannot work with .dart files named "login_event.dart" and "auth_service.dart", because Android Studio isn't recognizing them as .dart (no linting, just plain text, as you can see on the icon type in the picture).
I have over 40 other dart files in the project which all are working fine.
Just these two specific names can't be identified.
Even if the compilation of these to files is working, is is still annoying not to have advantages of normal dart files while coding.
Why this error occurs only exclusively with this naming, globally on my system regardless of AndroidStudio version and project is very incomprehensible to me.
It looks like Android Studio just doesn't want to recognize some names.
call flutter clean or to invalidate it using File > Invalidates Cache / Restart... ? solved the problem

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

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.

Android 3.4+ file encoding error causing projects to fail in loading and file to become unreadable

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

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.

Android Studio: Cannot resolve symbol, however build runs OK

Some time ago, I imported Urban Airship into my Android studios project. Everything was fine until recently when it can no longer resolve the corresponding symbols. The code runs fine, it just gives me the red errors if I open the files and so intellisense cannot resolve.
I've tried deleting everything and checking out the project again (no iml files or .idea/.gradle directories are committed), deleting my AS settings from the user directory, invalidating caches from the file menu.
So I ended up having to completely reinstall Android Studio due to having made a custom proguard jar and Android not understanding it can overwrite it and the issue went away. This was an update from 1.1 to 1.2, which made a completely different install directory for all of the components. I'll update if I find any more details.

Categories

Resources