Please look at snapshot of the opened file below.
When I double click on MyUtils.java it is showing this XML format:
But when I open it manually from Windows Explorer it already have correct Java code inside:
I have tried these but the problem remains:
clean, rebuild project
invalidate cache and restart
deleted .gradle and .idea auto generated folders from the project
updated and restart Studio.
It happens because of wrong File Encoding and you can see my answer about it in here.
Solution: The solution will be reinstalling Android Studio or, go to:
File -> Other Settings -> Default Settings, find File Encodings, change Project Encoding to System-Default or UTF-8 format.
try 'Sync Project with Gradle Files'. you can find it in top-left in 'File' tab or click on button at the left of 'Avd Manager' button.
go to Project mode and right click on the root folder of your project and Synchronize it
Actually you do not need to reinstall the Android Studio.
I met with the similar problem. The way to fix it is if you are using MAC OS then goto
'Android Studio->Preferences->Editor->File Types'
then check the Recognized File Types and look for your bug file in Registered Patterns and remove it.
Then all be good.
Related
Can someone please explain to me what this error is and how to resolve this error?
Gradle sync failed: D:\SoundsandPictures.gradle\4.4\fileHashes\fileHashes.lock (Access is denied)
Note: My project was on D: drive and i accidently deleted all my data on the drive and recovered it using a recovery software and getting this error while opening the project in android studio.
Goto File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio (It will download gradle metadata and data)
Gradle build succeed
Rebuild project. Done.
EDIT
Try this for Mac OS
Go to SDK manager (with Administrator rights), scroll down till the end, download "Android Support Library".
And it works (don't forget Administrator rights).
Reference this SO Question..
If do you have an antivirus software, try to check if it has blocked Android Studio.
In my case, I hid the .gradle file. On unhiding the file, it was fine.
Very late answer, but
I was getting the error "caches\5.1.1\file-changes\last-build.bin (Access is denied)",
deleting that file and re-building the project worked for me.
/.gradle/4.6/fileChanges/last-build.bin%20(Access%20is%20denied)
I resolved this issue by deleting .gradle folder and then restart android studio
clean and rebuild
i deleted the file, then appear another message but with other file, i did the same 3 times, and then a clean and rebuild and worked.
PS: those files regenerate after the build, so no problem there.
Same error was showing while doing in vs code. I solved just by deleting this .gradle\caches\6.1.1\file-changes\last-build.bin file. After relaunching the vscode the problem wa
make files not hidden (unchiek hidden in windows)
it means that you have no right to access that file, in my case it was on *.jar files at c:\gradle subfolders so I solve it by cmd:
C:\icacls "[PathToYourDeniedFilesOrFolderLikeC:\gradle]" /grant [YourWindowsUserNameHereLikeUser]:(OI)(CI)F /T
if it did not work you can right click on that file go to security tab then add yourself to get full permission on it. Good Luck Coding . . .
Hope this Helps ^_^
OK.. To solve this issue, simple navigate to your project folder like C:\Users\AndroidStudioProjects\Project.gradle\taskArtifacts folder and delete the file. The fileHashes.lock is holding a global lock and is preventing you from running your script. Deleting the folder would create the file again and your project will get built. Also there is a possibility that there are other locked files. Simply delete everything within the C:\Users\Administrator.gradle\caches folder.
Create a new Android project and move all your recovered files into it. This issue you are facing is because of existing settings in the old project.
Then ...
Go to File--> Project Structure --> Check Use Embedded JDK (Recommended)
whenever this happens
JUST DEL (MAKE A BACKUP 1ST) THE CULPRIT FILE (THE FILE RIGHT BEFORE THE MSG "ACCESS IS DENIED"
hope this helps
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.
I follow all the necessary steps for Android Studio installation. I also checked this question, but still facing the same issue.
But whenever I create any new project, following screen come. I couldn't found any project structure as I can see in Eclipse.
Here, I can't find any "src","res" or any file structure. Any idea, how to get proper Project Structure?
when I tried to add "New Module" following error comes to submit.
No message
java.lang.IllegalStateException:
at com.android.tools.idea.wizard.NewModuleWizard.onFailure(NewModuleWizard.java:159)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:340)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$1.run(ExternalSystemUtil.java:364)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:493)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:304)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
at com.intellij.openapi.application.impl.ApplicationImpl$10$1.run(ApplicationImpl.java:695)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:458)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:154)
When I go to Edit Configuration, can't create any module due to above error.
Go to File > Project Structure > Project Settings > Modules.
Click on the green colored + and add new module.
select Application module and set the content root to your project module.
Click next and then finish.
This should do the trick and the complete project structure will appear.
It worked for me.
Change the SDK to a level that you have installed in the SDK manager. The SDK manager can be accessed from Tools -> Android -> SDK Manager. For me, Android Studio was packaged with API Level 17 but the new project wizard tried to target API Level 18.
When something like that happens to me, to fix it, I go to
File -> Project Structure -> Modules, click (+) to add a module.
To import the main module you have to search for the IML extension file to load the project structure configuration again (for example app.iml), and thats all. I hope it helps.
Kip2's solution worked for me with a slight variation:
1.) File -> Invalidate Cached/Restart..
once android studio restarts:
2.) File -> Sync Project with Gradle Files
Just doing "File -> Sync Project with Gradle Files" (or doing "File -> Sync with File System"), did not correct the problem. I had to invalid the cache first, and then sync the project with gradle files for the project to display properly.
Finally find solution.
Whenever Android Studio starts, it search for "Gradle" installation. If not found, it will download new version of it and cache it here.
C:\Documents and Settings\user\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok
Here 72srdo3a5eb3bic159kar72vok directory name may be different.
What you need to do is, download gradle-1.6-bin.zip, place it in above directory. Then decompress it there. But make sure your path should like below.
C:\Documents and Settings\crathod.SOLUSOFTINDIA\.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\gradle-1.6\bin
Now, when you restart your Android Studio, Gradle will be initialized and Project will opened in Full Project Structure.
Modules or the project structure could also not appear because you're in a branch where *.iml files are missing. This happened for me when I was migrating from Eclipse and had decided to check back into the original branch that had the Eclipse-like project structure. What solved my problem:
Checkout the branch with Android Studio-like project structure
File -> Invalidate Cache & Restart
Also, make sure that the root iml file matches case with your root folder. Incorrectly named iml file will cause such problems.
Just delete the root iml file (you can backup if you like), close the project and re-open it. Android Studio will generate the correct iml file and the project structure will be restored.
This is tested on Android Studio 2.1
Before:
After:
I got the java folder (src folder) and others.
Solution:
File > Sync Project with Gradle Files
Android Studio Version: 3.2.1
Note: This case did not appear on the old version. For example, 1.5.1 (2016/03 before)
Keywords:
file explorer
file structure
file hierarchy
file system
folder & file list
project explorer
project structure
project hierarchy
disappear / gone / did not see
Android Studio bug / issue
simple way to restore
Delete the project hidden .idea file and .gradle file and restart your project this will fix your issue.
I deleted the app from the list of apps when you open Android Studio, then I reimported the project.
For Android Studio 2.2, you can simply click the left bottom and then select Project
In Android Studio 2.3.1, you don't have the Application module option if you wanted to add a module. The best solution is to right click your project and select "Jump to the source" from the menu. That solved my issue.
When i create new project in android, i found each and every time error sign on project name just like picture, that could not run? So is that any solution to remove this error?
default.properties file seems like this, which is message from error log.
Have you tried going to Project->Clean... in the menu? This sometimes will help. Also try unchecking Project->Build Automatically and then right click on your project and run as Android.
Edit: You may also have to delete your debug.keystore file. This file should be located in your home directory. Then try clean and build from eclipse and the file should then get recreated.
I used to have a similar proble. Restarting eclipse might resolve it.
Give this a try to fix your properties.
Right-click the project -> Android Tools -> Fix project properties
When I changed some design in .xml file, R.java file automatically deleted. How can I get back that file and what is the solution to resolve this problem, that in future this problem does not occure.
check all your errors in xml files structure (layouts, string etc...) even if sometimes they are not easy to spot.
My advice is to undo the latest things you've done until you find where the errors were and fix them.
Once they are all fixed the R file will be created again (maybe you need to clean your project: project -> clean)
In the future just try not to break the xml files and this won't occur again xD
You can also disable automatic build in your Eclipse IDE(Menu -> project- > Uncheck build automatically). This way the R file will be recreated only when you manually build the project and not when you save changes in an xml file.
Fix your errors and the R.java file will return...e.g when i added an image in my resources folder its name was in uppercase....when i changed it to lowercase,immediately after doing it my R.java file returned...its all due to errors...just fix them and it will return
I agree with #maid450.
I also have faced similar situations.
If your problem isn't resolved after all this, ultimate option is to create a new project, and copy files to it.
one solution is that Go to Eclipse project tab -> uncheck Build Automatically -> Clean the project.Make sure that there is no error in your project also don't try to edit the R.java file one it will created. Then manually build the project. you will get the r.java file.
The best solution for Mac/Eclipse user is to go to the SDK Manager and re-install the Android SDK Build-tools, and then restart Eclipse.
For some reason after performing a Clean action on a project the R.java file for all projects happens to be deleted from the system.
Clean the project.
Menu [Project] -> [Clean...] -> Select you project -> [OK]
Project will rebuild automatically, if not, chek
Menu [Project] ->[Build Automatically]
The R file deleted automatically when I changed my activity_main.xml in Android Studio.
What I did was copy the R java file from another project and paste it into the project in which it got deleted.
Hope it helps. :).
Location for R file.
Project/app/build/generated/source/r/debug/com.android.'projectname'/R.java
Where is the R.java file in Android Studio?