spawnSync ./gradlew EACCES error when running react native project on emulator udara

React NativeGradleAndroid Gradle-Plugin

React Native Problem Overview


I am trying to use react-native run-android to install my react-native application on an android studio emulator. I have checked with abd-devices that the emulator is available, and I have ran npm-install.

I am using Ubuntu 18.04 with the latest version of android studio, and the latest Pixel 2 XL API 28.

I get the following error:

spawnSync ./gradlew EACCES

Error: spawnSync ./gradlew EACCES
    at Object.spawnSync (internal/child_process.js:998:20)
    at spawnSync (child_process.js:622:24)
    at Object.execFileSync (child_process.js:650:13)
    at runOnAllDevices (/home/user/react/front-end/project/node_modules    /react-native/local-cli/runAndroid/runAndroid.js:299:19)
    at buildAndRun (/home/user/react/front-end/project/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
    at isPackagerRunning.then.result (/home/user/react/front-end/project/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

I have tried restarting my PC and the emulator several times. Any ideas?

UPDATE: I reinstalled JDK, npm, react-native-cli and android studio. It still gives me the exact same error. Please help.

React Native Solutions


Solution 1 - React Native

I fixed this problem with:

chmod 755 android/gradlew 

the chmod command sets the permissions of files or directories. https://www.computerhope.com/unix/uchmod.htm

Solution 2 - React Native

I think it's permission issue I faced this problem before, you can resolve it by changing the permission, run the following command

chmod 755 android/gradlew

Solution 3 - React Native

I tried the above solution.but in my case I had to use sudo because of the permission issue. You can resolve it by running the command

sudo chmod 755 android/gradlew

Solution 4 - React Native

For mac this worked for me:

sudo chmod 755 android/gradlew

Solution 5 - React Native

It turns out that It's not gradle but it's android/gradlew. run the below command inside the root directory:

$ chmod +x android/gradlew

Now run

$ yarn android            
# OR   
$ npm run android 
# OR
$ npx eact-native run-android

You should be good to go.

Solution 6 - React Native

For Big Sur (Apple MacBook Air M1 Chip)

chmod 755 android/gradlew worked

Solution 7 - React Native

On the first approved answer from @Jinkey, in case you are wondering where to run this command, like in my case on Mac, follow these steps:

  1. In your terminal navigate to your project folder cd <project folder>, make sure the path to your project is correct.
  2. Then once in the folder, run the command by copying and pasting as is chmod 755 android/gradlew

Solution 8 - React Native

that's worked for me chmod 755 android/gradlew

Solution 9 - React Native

On MacBook Air M1 chip chmod 755 android/gradlew works great. Also add the below line in the android/local.properties file.

sdk.dir = /Users/YourUserNAME/Library/Android/sdk

Solution 10 - React Native

I think it's permission issue I faced this problem before, you can resolve it by changing the permission, run the following command

chmod 755 android/gradlew

Solution 11 - React Native

The issue is related to permissions, try this command.

chmod 755 android/gradlew 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondudeperryfectView Question on Stackoverflow
Solution 1 - React NativeJinkeyView Answer on Stackoverflow
Solution 2 - React NativeOmar Al-HoweitiView Answer on Stackoverflow
Solution 3 - React NativeLakshan MamalgahaView Answer on Stackoverflow
Solution 4 - React NativeSaif Bin Abdul KarimView Answer on Stackoverflow
Solution 5 - React NativeEricgitView Answer on Stackoverflow
Solution 6 - React NativeAli AbbasView Answer on Stackoverflow
Solution 7 - React NativeNicholas MberevView Answer on Stackoverflow
Solution 8 - React NativeAhmed RazaView Answer on Stackoverflow
Solution 9 - React NativeC BaraliyaView Answer on Stackoverflow
Solution 10 - React Nativewahyu setiawanView Answer on Stackoverflow
Solution 11 - React NativeHarsh VaidView Answer on Stackoverflow