2
votes

Trying to run my React Native app in Android emulator but it keeps throwing error:
"Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html error spawnSync ./gradlew EACCES. Run CLI with --verbose flag for more details."

Tried react-native run-android, npm start, react-native start... nothing worked!!!

enter image description here

enter image description here

Am I missing out something here?? struggling with this since morning. Please help....

Update:
Ran "adb devices" in terminal. Still its not working :/ Same error!!!

enter image description here

3
Import the project in Android Studio, let gradle configure all dependencies and start the app again using react-native run-android.Alpha 1

3 Answers

3
votes

Check the permission on android/gradew. It should be 755 and not 644.

Run the following command inside your app root folder:

chmod 755 android/gradlew

The run: react-native run-android. If you are on Windows, make sure to run react-native run-android in CMD as administrator.

Hope it helps :)

EDIT for the new problem in the comments:

The following are a few ways you can try to fix the error you mentioned in the comments:

1) Go to FILE -> sync project with gradle files.

If no.1 doesn't work for you. Try no.2

2) Go to .gradle\caches\2.0\scripts\build_7l4t45nbnsvdcl79ol8u0beli4\ProjectScript and remove the cache.properties.lock file. If you are on windows try this as: C:\Users\<username>\.gradle\caches\<gradle version such as 2.4 or something else>\scripts>del /S *.lock

Hope this solves your problem :)

EDIT 2:

You can downgrade from your Java 13 to Java 8. It may solve your problems. However, if you are unwilling to downgrade go to build.gradle and do the following:

compileJava.options.fork = true
compileJava.options.forkOptions.executable = /path_to_javac

If you do the following above instead of downgrading you will set a concrete path which will hinder your project if you are sharing it with other developers.

This was the best I could come up with from simulating the same problem on one of my test projects in my computer. Hope it helps :)

2
votes

Check if you actually have a device connected by typing this in terminal

adb devices

If there is no device detected.

Try typing this in terminal

adb kill-server
adb connect 127.0.0.1:62001
adb devices

If it looks like this

devices ready

Then you have no problem with Android devices. Try running the app again with

react-native run-android

If it's not working, try

cd android
./gradlew clean
cd ..
react-native run-android
0
votes

please add you skds path in windows or mac path environment

enter image description here