问题
I am attempting to run gradlew from my command line, but am constantly facing the following error.
Brendas-MacBook-Pro:appx_android brendalogy$ ./gradlew compileDebug --stacktrace
-bash: ./gradlew: Permission denied
I am already running this command from my project directory. Need to run this command as I am facing the same (nondescriptive) error on Android Studio 0.2.x as encountered here: Android studio and gradle build error
Am I doing something wrong and how do I get around this?
回答1:
Try to set the execution flag on your gradlew file:
chmod +x gradlew
回答2:
Could also be fixed with
git update-index --chmod=+x gradlew
回答3:
You could use "bash" before command:
bash ./gradlew compileDebug --stacktrace
回答4:
Jenkins > Project Dashboard > (select gradle project) Configure > Build
x Use Gradle Wrapper
Make gradlew executable x
回答5:
You need to update the execution permission for gradlew
Locally: chmod +x gradlew
Git:
git update-index --chmod=+x gradlew
git add .
git commit -m "Changing permission of gradlew"
git push
You should see:
mode change 100644 => 100755 gradlew
回答6:
git update-index --chmod=+x gradlew
This command works better especially on non-unix system.
回答7:
if it doesn't work after chmod'ing make sure you aren't trying to execute it inside the /tmp directory.
回答8:
Try below command:
chmod +x gradlew && ./gradlew compileDebug --stacktrace
回答9:
In my case, I had executed permissions and I couldn't run gradlew even with sudo. my problem was my project was in another hard drive and I didn't have exec permission on that drive. I simply removed noexec mount flag from fstab and added exec flag. then remount the disk so changes apply.
来源:https://stackoverflow.com/questions/17668265/gradlew-permission-denied