简体   繁体   中英

Android emulator not running with my React Native App

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!!!

在此处输入图像描述

在此处输入图像描述

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!!!

在此处输入图像描述

check if you actually have 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

设备就绪

then you have no problem with android devices. try running the app again with

react-native run-android

if its not working, try

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

hope this can help you:)

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:)

please add you skds path in windows or mac path environment

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM