This question already has answers here:
Android Studio shows wrong file contents
(10 answers)
Closed 4 years ago.
I am using android studio 3.3, my project is using kotlin 1.3.20 with build gradle 3.3.0
however when i try to open xml file, it open different file with the right file name and the right file path:
And when i try to see this xml file in my Git, my file is normal
when i try to run this project, it run with no problem at all.
i already try to invalidate caches/restart but the problem still exist.
this error affecting random xml files. some of my xml layout files open my kotlin file. some of them open auto generated file
please help.... is this something to do with error indexing? how can i fix this?
UPDATE :
found someone who might have the same problem with this, in google issue tracker : https://issuetracker.google.com/issues/122988154
UPDATE 2 :
this issue is not just happen in xml file but also in kotlin file.
i try to open my activity file, but it open one of data binding generated classes
So Apparently this issue is bug in Android Studio. after do some research, this bug might be happen not just to xml layout but other xml file too such as resource like dimens, strings, style etc..
finally there is some workaround for this issue that work without reinstall Android Studio.
Thank you #ChetanJoshi for the suggestion in the comment section.
Steps:
Copy the error xml file to somewhere in your PC directory (as backup file)
Delete the error xml file, if there is dialog file usage appear klik delete anyway
Copy the backup file and paste it back to where it was deleted
Run your project. it should run
If you are using Data Binding and there is error appear about auto generated data binding
class, Clean Project then rebuild project. if the error still appear try to invalidate caches/restart, rebuild project then run the project
Restart your Android Studio, if not working, Restart your PC.
or
Go to plugins -> Android support and disable this. Restart Android studio and enable the plugin again
After that don't forget to Refresh your Gradle project.
I am new to AndroidStudio AND Gradle.
I imported a project from eclipse, created a module, and tried to run the project, but I got this error:
AndroidManifest.xml doesn't exist or has incorrect root tag
I have been looking at this previous solution for it:
How to build an android library with Android Studio and gradle?
But that solution is WAY too advanced for me.
Could someone please help me understand in simpler terms what is going wrong and how I can fix it?
Thank you!
Update after one of the answers:
These are the options I have under the build menu:
clicking on Sync project with Gradle files button will solve your problem.
That button is under File section on Android Studio 3.6.1
Close your Android Studio
Goto C:\Users\user\.AndroidStudioX.X\system and DELETE the cache
folder
Launch the Android Studio
Goto Build (menu) -> Clean Project when done click the
Build (menu) again and click rebuild project.
That should solve the problem.
For me the issue went away once I opened the android folder of the project in Android Studio to run the project.
So basically, because I was trying to run the Android project from the Root folder, it gave me the error. We need to run the project by selecting the android folder of the project only.
Hope this helps someone!
Click on File > Invalidate Cache/Restart, and that's it. Your project should start working.
For me clicking on Sync project with Gradle files button did not solve the problem alone.
After Syncing project with Gradle files, I explicitly had to invalidate the cache and restart studio. Only after this action, the red cross-mark over configuration disappeared and everything started working.
In my case, my android project got corrupted and some of the files were showing characters, binary numbers, etc. I tried the following solutions
Invalidate & Restart
Rebuild Project
Sync with Gradle File
But none of the above solutions worked for me.
Then I just deleted the cache folder under C:\Users\username\.AndroidStudio3.6\system
and all the invalid characters disappeared and the actual contents of all the files were displayed. This solution worked for me.
Every Android project needs a file called AndroidManifest.xml to tell Android about itself. Either your project doesn't have one, or it's not in the place that Android Studio expects it to be. Try to find it, and move it to the root folder of the project.
1.Check whether the manifest file is there or not.
2.If it is there, check whether the package name is correct or not..
3.If you project has small number of classes, then you create new project in android and then copy paste your code from eclipse. It will be simple. But it is recommended only for small project.
And finally click 'Sync' in the Gradle file. Followed by Rebuilding the project will do a trick.
In my case the Manifest file seemed to be corrupted or maybe its meta data. Trying to open it in Android Studio will show some characters that you see when opening a binary file with a text editor, for ex. Anyway, my project is under Git, so I just deleted it and restored it back, problem fixed.
Go to C drive click User then select your android studio folder then select System find Cache folder and delete this folder before doing this close your android Studio.It will surely work.
I also had this problem, things I tried:
I delete user->gradle-> delete cache folder
Android studio-> file-> Invalid cache/restart
Using my problem is get resolved
I also had this problem, things I tried:
Syncing the file with gradle
Invalidate/Restart
But the problem was still there in the manifest folder-> manifest.xml file it had only 1 line.
So I went to User-> your_username -> Android Studio v -> caches and Deleted the cache folder.
Started Android Studio, and my problem was gone.
But I am not sure which of these might solve yours.
I have opened AndroidManifest.xml in file editor. Add some letters, save it, then android studio found AndroidManifest.
After this I can build project successfully
if your AndroidManifest.xml looks wierd than you can try checking local history or git history. by doing that you can copy paste the previous version AndroidManifest.xml
Experienced that too, there is a line on your manifest code that's incorrect, simply go through it and make necessary corrections.
when running apps i am seeing duplicate layout file, which is not delete sometimes. when try to delete this file this error comes out.
I have login.xml file, after running project the adding new xml login.out.xml.
I faced many times such types of problem. so can you guys tell how to generated this duplicate file? when?
This happens when you try to run the application while an xml file is currently the open tab on the editor. Just delete the file and clean the project. After that, run the project with a java file as the opened tab on the editor.
Here is a bug filing about this.
If you are changing into the login.xml file and after completion of changes you are using ctrl+f11 to run your application at that time the login.out.xml file is created, this problem is generated after update ADT plugin to 20.0.3.v201208082019-427395, so first close the login.out.xml file and after you can delete this file, sorry for my bad English and see below link for more information.
How to fix the main.out.xml issue
Android: main.out.xml error
I am trying to create an android project using eclipse IDE,its created successfully but the problem is in error log.After creating of a project with name as android_test,the error shown failed to load properties file for project 'android_test'.
Can any one let me know how to over come this problem.
Thanks for your time!
Start again and be sure to
have write / read permissions in the folder of your project
avoid special characters when naming things (project/classes/files/etc)
I have a problem where Android projects I create in Eclipse are unable to run/debug.
In the Package Explorer, there is the small red cross in the top Project Folder which signifies an error somewhere, but there are none in the lower level files of the Package Explorer.
When creating the project, an event appears in the Error Log stating: "Failed to load properties file for project 'HelloAndroid'"
I have tried:
Looking elsewhere in forum at similar issues
Reinstalling Eclipse, JDK, SDK, ADT
"Cleaning" the project
The error remains.
What could have caused this problem and what is the solution?
Thanks
try to see the problem... open the problem tab. Window > Show View > Problems
paste here, maybe I can help you better with more information
regards
Go to “C:\Documents and Settings\.android” OR “C:\Documents
and Settings\\Local Settings\Application Data\Android” and
delete debug.keystore file. (Linux: $HOME/.android)
Recompile the project and the error should be gone.