Freshly Installed Android Studio and started new android project.
When tried to run it. Got this error from Gradle
Error:Could not open initscript class cache for initialization script 'C:\Users\Dexter\AppData\Local\Temp\asLocalRepo10.gradle' (C:\Users\Dexter\.gradle\caches\2.2.1\scripts\asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv\InitScript\initscript).
java.io.FileNotFoundException: C:\Users\Dexter\.gradle\caches\2.2.1\scripts\asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv\InitScript\initscript\cache.properties (The system cannot find the file specified)
I have tried to rebuild the project and also tried to delete .gradle folder but nothing worked.
I'm having the same problem and deleting just the cache.properties.lock is not enough.
The solution, as pointed before, is deleting the cache.properties.lock file, but not only in the folder pointed by Android Studio. I needed to remove every lock file inside .gradle\caches\VERSION.
So, I created a small .bat file with this:
del /s cache.properties.lock
Add this file to .gradle\caches\VERSION\ and run it. My Android Studio stopped complaining afterwards.
Hope it helps!
Error Message
Error:Could not open initscript class cache for initialization script
'C:\Users\Dexter\AppData\Local\Temp\asLocalRepo10.gradle'
(C:\Users\Dexter\.gradle\caches\2.2.1\scripts\asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv
\InitScript\initscript)
java.io.FileNotFoundException: C:\Users\Dexter\.gradle\caches\2.2.1\scripts\
asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv\InitScript\initscript\cache.properties
(The system cannot find the file specified)`
The most important parts of this error message are
- Could not open initscript class cache
- asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv
So
Let _XXX_ = asLocalRepo10_d10e66d3o7exs19wwq4uj2zhv
Let _USER_ = Dexter
Let _GRADLE_ = 2.2.1
Solution
Delete
C:\Users\_USER_\.gradle\caches\_GRADLE_\scripts\_XXX_\InitScript\initscript\cache.properties.lock
Does this not work?
Then you have to find out the root solution. This is probably due to a corrupt IDE. Try installing another copy of Android Studio on your system.
Note: You can have multiple copies of Android Studio on your system. Here is the latest Preview. If you check the notes on the page, you can see what you need to do to install a new version on AS.
Let us know if this works...if not, we can try to elimate other possible issues
go to location
".gradle\caches\2.0\scripts\build_7l4t45nbnsvdcl79ol8u0beli4\ProjectScript"
delete cache.properties.lock file
I am also getting the same error.
So what I did is this that I cleared the Temp folder (If you don't know where it is then just hit Window+R and enter %temp% OR you can type %temp% in address bar too in File Explorer).
Now again run the project, it should run fine.
I don't know the permanent solution but what I am telling it works for me.
If anyone do know the permanent fix then please share that.
In my case, it was the roaming profile issue. Gradle Sync failed every time I switched networks from work to home. Although I was able to access the network drives by connecting with VPN, still it used to give this error. I had to move the Gradle Service Directory Path to a different location that wasn't dependent on the network.
You can do this in AS 1.4 by going to File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Service Directory Path. Screen shot below:
You can also add GRADLE_USER_HOME environment variable with the same value of the location for making it a default for every project (http://blog.james-carr.org/2011/05/04/setting-gradle-cache-to-a-common-location/). You may refer to the following page for more info on moving Android related stuff to different locations: http://www.littlecpu.com/android-studio-c-drive
File -> Invalidate Cache / Restart worked for me.
In my case I have deleted .gradle folder and clean the project on re run the project was working fine.
I had similar issues. For me the solution was simply to delete all files inside the folder C:\Users\Dexter.gradle\caches\2.2.1\scripts\ Also i removed VCS configuration from android studio. No need to install new Android Studio to fix the issue.
I have same problem. just restart your Gradle and then clean your project. i hope this help
For Me Issue get resolved by giving permission
For window
C:\Users
Right click on Users >> Click on Security Tab >> Add Group and username there
as for example SYSTEm, your comany mail id
For Linux
provide 777 permission for .android and .gradle folder by using
sudo chmod 777 -R .android/
sudo chmod 777 -R .gradle/
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
After updating my Android studio today I created simple project and I got following error that.
Error:Could not set process working directory to 'E:\DevelopAndroid\myNewProject': could not set current directory (errno 5)
The 'E:\DevelopAndroid\' is exist and the 'myNewProject' folder created.
But still I can't upload the code to my Git server.
I am not able debug it.
And I don't know what to do.
Renaming directory without space
delete .idea folder
Restart Android Studio
It will work
close current project, delete it and create a new same project, it works for me.
under your project-> look a folder(.idea) delete everything in it. then go to file-> select sync project with gradle files click and let your project sync again
I solve this by assigning full control permissions to the root directory in my Windows 10 machine. In my case cdm-webservice-v2 is the project directory.
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.
Error:Could not open initscript class cache for initialization script
'C:\Users\Subash\AppData\Local\Temp\asLocalRepo2.gradle'
(C:\Users\Subash.gradle\caches\2.2.1\scripts\asLocalRepo2_cd0g6mnzdabuvxgeqlhhrxv0q\InitScript\initscript).
java.io.FileNotFoundException:
C:\Users\Subash.gradle\caches\2.2.1\scripts\asLocalRepo2_cd0g6mnzdabuvxgeqlhhrxv0q\InitScript\initscript\cache.properties
(The system cannot find the file specified)
UPDATE:
Check my answer here for full details
I have the latest version of Android Studio and I faced that problem, the only thing that worked for me is to:
1-Navigate to C:\Users\user.gradle\caches\2.4\
2-Copy the folder "scripts" and paste it somewhere safe just in case anything went wrong you will place it back
3-Delete this folder "scripts" from the directory C:\Users\user.gradle\caches\2.4\
4- Sync Project with Gradle Files and you are done.
When you sync your project Android Studio will generate new cash files.
It worked for me I hope it will work for you...
I don't know why a great developer as Google can't manage this issue by them selves it is very easy to delete the cached folder and regenerate it programmatically. Any way just navigate to C:\Users\user.gradle\caches\ and open the latest version folder, then delete the scripts folder. Go to android studio and sync project, that should do it.
Exit Android Studio, remove the Gradle cache folder which path is in the error message, and restart.
You could try to delete this : C:\Users_USER_.gradle\caches_GRADLE_\scripts_XXX_\InitScript\initscript\cache.properties.lock
I had the same problem and after deleting it all works fine.
Another common problem with Gradle is synchronization which is solved adding the correct path of JDK but this is another story.
I hope to help.
I just install android studio on a VM machine (VM Fusion). When I try to create a new project, I get the message "org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'."
I followed the suggestion found in the page.
Download Gradle directly from
http://services.gradle.org/distributions/gradle-1.6-bin.zip
Copy the contents of gradle-1.6 to
\Android\android-studio\plugins\gradle
Copy gradle.jar to \Android\android-studio\lib\
Restart Android Studio
It did not work. I get the error message
I tried to copy the zip package /gradle-1.6-bin.zip to the following location
C:\Documents and Settings\myusername.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\
the .gradle file was not there. I look in setting and notice that it under \vmware-host\sharefolders. I went there and the file was still not there. I unhide hidden file and folder with no luck.
In addition, when I create a new project, I notice the project location is \vmware-host\Shared Folders\AndroidStudioProjects\MyApplicationProject.
How can I get a new .gradle file or tell android studio to look at a different folder? How do I change the project location so it does not default to \vmware-host but instead to c:\development.
Any kind of help would be greatly appreciated.
Thanks,
JF
Copying Gradle inside Studio will not help. Just install it somewhere else and after manually creating a project you can import it in Studio and select which installation of Gradle to use.
You have to create the project manually, because right now creating a project from studio always use the wrapper that automatically download gradle from the online repository.
We are working on having an offline mode for project creation, but it's not available yet.
Just edit your System's DNS settings, and redirect services.gradle.com to 127.0.0.1 then use a small web server and serve the file under its appropriate directory (distributions)
As you said,"Copy the contents of gradle-1.6 to \Android\android-studio\plugins\gradle",this folder under the setup path.
Why did you copy it to "Documents and Settings"?