[gradle] gradlew: Permission Denied

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?

This question is related to gradle android-studio gradlew

The answer is


Just type this command in Android Studio Terminal (Or your Linux/Mac Terminal)

chmod +x gradlew

and try to :

 ./gradlew assembleDebug

enter image description here


Could also be fixed with

git update-index --chmod=+x gradlew

I got the same error trying to execute flutter run on a mac. Apparently, in your flutter project, there is a file android/gradlew that is expected to be executable (and it wasn't). So in my case,

chmod a+rx android/gradlew

i used this command and execute the project


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

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.


This error is gradle permission related . Just paste below line in your terminal and run...

chmod a+rx android/gradlew


Jenkins > Project Dashboard > (select gradle project) Configure > Build

x Use Gradle Wrapper

Make gradlew executable x

enter image description here


This issue occur when you migrate your android project build in windows to any unix operating system (Linux). So you need to run the below command in your project directory to convert dos Line Break to Unix Line Break.

find . -type f -print0 | xargs -0 dos2unix

If you dont have dos2unix installed. Install it using

In CentOs/Fedora

yum install dos2unix

In Ubuntu and other distributions

sudo apt install dos2unix

if it doesn't work after chmod'ing make sure you aren't trying to execute it inside the /tmp directory.


git update-index --chmod=+x gradlew

This command works better especially on non-unix system.


You could use "bash" before command:

bash ./gradlew compileDebug --stacktrace

chmod +x gradlew

Just run the above comment. that's all enjoy your coding...


Try below command:

chmod +x gradlew && ./gradlew compileDebug --stacktrace

With this step set permission to gradlew

steps {
    echo 'Compile project'
    sh "chmod +x gradlew"
    sh "./gradlew clean build --no-daemon"
}

on android folder cmd run

chmod +x gradlew

and run

./gradlew clean

and root project run

react-native run-android

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to gradlew

Gradle: Could not determine java version from '11.0.2' Difference between using gradlew and gradle Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease' Difference between clean, gradlew clean Could not find or load main class org.gradle.wrapper.GradleWrapperMain How/when to generate Gradle wrapper files? Android Studio: Plugin with id 'android-library' not found gradlew: Permission Denied