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.
Related
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?
Suddenly my Android Studio always generates the colors.xml file with junk characters when creating a new project. I have scoured the internet and found no answer. Does anyone have any idea as to why this is happening?
I'm using Android Studio 3.2.1 which I just updated recently. But, the problem already occurred in the previous version. At first, I thought that this is an encoding problem, but my settings already specify UTF-8 for all files. Also, opening the same file in other text editors display the same result.
Of course, I can just edit and replace the colors.xml file with the correct content. But, I fear this problem will escalate in the future if I leave them.
Here is a screenshot of the file in question:
Here is the screenshot of my setting:
Let me post an answer for future reference. The problem was solved by uninstalling Android Studio and clearing all settings. After I reinstall Android Studio the problem was corrected.
On Windows 10, I chose "clear user settings" while uninstalling. I also deleted the .AndroidStudio and .AndroidStudio3.2 folders in "C:\Users[user]\" after I backup those folders. After that, I reinstall Android Studio and redo all the settings. Now my Android Studio can create a new project without a problem.
Android Studio 3.2.1I found a solution! Just delete user settings folder ..\Users\%USERNAME%\ .AndroidStudio3.2
So far after much investigation, I got as far as finding Tools->Archive Manager in Visual Studio 2017; however, I have no idea where to put archives to be viewed in this manager.
Other than Current Solution there is an All Archives menu on the left side, which looks like a Global repository, but I cannot seems to add anything to it.
Drag-n-drop does nothing either. I even tried creating a new Android project and dropping the .apk files into the bin folder and still nothing, so I'm at a loss.
Is it not possible to open 3rd-party APK files in Visual Studio (the ones I have are unsigned) in order to sign and test it in the emulator?
I'm new to Android development (and to gradle), as is our small team. We have one developer who has been working on a project for a couple weeks, and who has been checking their code into GitHub periodically.
When I download their code and attempt to open in Android Studio 2.2, I get asked about various project settings. This surprised me, because it seems that all the project settings should already be specified somewhere in a file saved in the project settings. My coworker ought to be able to save all of their project configuration settings into the project file, upload it to the repository, and I should be able to download all of his files and simply build and run the project on my machine, assuming we're running the same version of Android Studio and both have the same SDK(s) installed.
My question is, what file(s) contain the project settings under Android Studio 2.2 and 2.1 (the version he started development with)? I've tried searching online and here on stack overflow for "what file contains project settings in android studio". However, this only gets me results that talk about what a project is, and what dialog boxes contain certain settings. I'd like to know which files (gradle, xml, etc) files contain the project settings (build, SDK, workspace, etc).
I've also tried uninstalling 2.2 and going back to 2.1.2, but that doesn't help much either. In both cases, I'm getting questions about project settings as well as build errors. I don't want to address all of those issues here though.
Thanks so much for you help!
From the location where you have installed Android Studio,
you will have something like .AndroidStudio2.2 folder this contains settings for version AndroidStudio2.2
What you do is Unistall studio and installng new one(AndroidStudio2.2), it will ask you to take settings from just give this path mentioned.
Other than this,
your gradle file will have all settings of your project.
it will be of module level and project level.
I'm using Eclipse (4.2.1 Juno) on Windows 7 for my Android 2.2 project. I have several PNG resources in my drawable folders, and I'm finding that if I edit my PNG files (Paint/Photoshop etc) Eclipse doesn't recognise the file has changed and the ADT graphical layout designer still displays the old version of the image. I've tried refreshing the project folders list, tried doing a Project->Clean but neither has any affect. The only way I've found of getting Eclipse to recognise the new image version is to exit completely and restart which is a pain.
Is there some setting I can use to tell Eclipse not to 'cache' the images and always read the latest version off disk?
Try in Eclipse Project -> Clean then select your project. This will delete your R.java file and will generate new one.
That is a common problem of Eclipse that it doesn't recognize external changes for files in the workspace. The only thing I have found out to remedy this problem a little (apart from refreshing like crazy), are the refresh settings in external tools configurations. That is, if you run for example an Ant build, you can tell eclipse to refresh the workspace or specific resources afterwards. I don't know of any automatic way to do this though.
you should try saving all the unsaved resources and files after adding images ,than try out again.try cleaning both options with cleaning your single working project and with cleaning all projects.
I don't know of an automatic setting, but I have found a relatively simple manual action that seems effective. I was having the same trouble as you; now the following procedure seems to work consistently for me, with Eclipse Juno 4.2.1.
Click on the "res" folder to select it, then press F5 to refresh. Also make sure your PNG file timestamps have been touched.
Resources cached in bin\res folder.
Create script which delete folder bin\res with all content.
Add this script as external tool in builder list.
Set position in builder list - after CDT builder. Second position in list. If no CDT builder - set it first.
Enjoy.