问题
Updated Android Studio from version 2.3 to 3.1 Canary. But there seems to be a huge problem with Gradle
.
Error:java.nio.file.AccessDeniedException: /home/pathname/.android/build-cache.lock
What I did:
- Deleted
.gradle
, thought it will solve the issue, but not, after rebuilding the project,.gradle
again appears. - Deleted all android related things from system (SDK, Android Studio and remaining projects) and from zero started to download Android Studio with all required packages. Still, the same problem.
- Changed android studio version from 3.1 canary to 3.0, also no success.
- Looked at this post, but didnt help.
- Read in some posts that this happens when Android Studio is corrupted. but I have downloaded from official site.
Any ideas how to fix it?
回答1:
I got the same error trying to Sync the project after an update. What solved the problem was giving the right permission to the .android folder, instead of running the studio on root mode (It would reinstall all SDK under root if you don't specify that you already have it under you user).
So, open the terminal and type:
sudo chown -R root:YOURUSERNAME /home/YOURUSERNAME_FOLDER/.android/
sudo chmod -R 775 /home/YOURUSERNAME_FOLDER/.android/
Easy fix, I hope it helps somebody.
回答2:
Open Android Studio as administrator..it worked for me.
回答3:
Solved, in Linux I changed ownership and mode of the directory to that of below:
sudo chown MyUserName:MyUserName
// This allows to change from administrator access to user access. Note it should be executed from there, where your android studio is located. Either it might be in/Home
or/Download
folder
sudo chmod -664
//This allowed files to be readable and writeable.
Reinstallation or other extra stuff dont seem to help, unless you do deal with proper root specification and file mode.
回答4:
For me the access is denied on my project files when the debugger stores data when compiling. For me I had to give access to the file/folder then delete it. Worked for me.
回答5:
In your project's main build.gradle, inside "allprojects":
allprojects {
repositories {
jcenter()
}
gradle.taskGraph.whenReady {
tasks.each { task ->
if (task.name.equals('mockableAndroidJar')) {
task.enabled = false
}
}
}
}
回答6:
26Sept2019: I'm having the same problem, bcoz i'm doing a project in Ionic 4 i got this WARNING: API 'variantOutput.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'.
(first then)
Android update causing error: Error:java.nio.file.AccessDeniedException: /home/path/android,etc.,... so i've deleted the Android folder in the ionic project folder, for example path: /Users/homefolder/Desktop/CommunityLoginApp/android deleted this file or moved to trash then i did below:
Running the Ionic app on Android(without $):
- ionic capacitor add android
- ng build
- ionic capacitor copy android
- ionic capacitor run android( for 1st time run - it will automatically open the Android Studio)/ if any changes done: run ionic capacitor run android -l (for live changes on the simulator).io
It worked perfectly and also i got the build in my physical android but a INFO shows in the output panel and the WARNING changed to INFO now. Cooooollllll
回答7:
You can either start Android Studio as an Administrator. But this might be just a workaround and is not practically for some people. Fortunately, there is another way of avoiding this problem:
- Open Explorer
- Go to the folder where the build-cache file is located
- Right-Click on it
- Change the permissions for the file to have full access as a User
This should solve the problem and worked great with a similar problem (android.lock file actually!)
来源:https://stackoverflow.com/questions/47164357/android-update-causing-error-errorjava-nio-file-accessdeniedexception-home-p