Reputation: 1917
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.
Upvotes: 190
Views: 108305
Reputation: 51
For me it was go to folder one above your project and run chmod -R a+rwx nameOfTheProject/ or if that doesn't work chmod -R 777 nameOfTheProject/
Solution found on this link https://edwardbeazer.com/how-to-fix-this-error-spawn-eacces/
Upvotes: 1
Reputation: 1305
gradlew
file permissions should be updated, you can resolve it by changing the permission, run the following command
chmod 755 android/gradlew
it will give (read,write,execute) permission for the user(owner), also (read, execute) for group and other users.
Upvotes: 81
Reputation: 7043
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 react-native run-android
You should be good to go.
Upvotes: 18
Reputation: 253
Go to the react native cli project directory then run this command below :
sudo chmod 755 android/gradlew
then run the command:
npx react-native run-android
then start the metro (if it is not started automatically) by following command:
npx react-native start
Upvotes: 1
Reputation: 21
sudo chmod 755 android/gradlew
works perfectly fine for this issue in mac!
Upvotes: 1
Reputation: 1841
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:
cd <project folder>
, make sure the path to your project is correct.chmod 755 android/gradlew
Upvotes: 3
Reputation: 1271
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
Upvotes: 0
Reputation: 333
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
Upvotes: 17
Reputation: 7006
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
Upvotes: 699