简体   繁体   English

Android 模拟器未与我的 React Native 应用程序一起运行

[英]Android emulator not running with my React Native App

Trying to run my React Native app in Android emulator but it keeps throwing error:尝试在 Android 模拟器中运行我的 React Native 应用程序,但它一直抛出错误:
" 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. " " 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错误 spawnSync./gradlew EACCES。使用 --verbose 标志运行 CLI 以获取更多详细信息。 "

Tried react-native run-android, npm start, react-native start... nothing worked!!!尝试了 react-native run-android,npm 启动,react-native 启动......没有任何效果!

在此处输入图像描述

在此处输入图像描述

Am I missing out something here??我在这里错过了什么吗? struggling with this since morning.从早上开始就在为此苦苦挣扎。 Please help....请帮忙....

Update:更新:
Ran "adb devices" in terminal.在终端中运行“adb devices”。 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.那么您对 android 设备没有任何问题。 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 .检查android/gradew的权限。 It should be 755 and not 644.它应该是 755 而不是 644。

Run the following command inside your app root folder:在您的应用程序根文件夹中运行以下命令:

chmod 755 android/gradlew

The run: react-native run-android .运行: react-native run-android If you are on Windows, make sure to run react-native run-android in CMD as administrator.如果您使用的是 Windows,请确保以管理员身份在 CMD 中运行react-native run-android

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. 1) Go 到 FILE -> 将项目与 gradle 文件同步。

If no.1 doesn't work for you.如果 1 号不适合你。 Try no.2试试 2 号

2) Go to .gradle\caches\2.0\scripts\build_7l4t45nbnsvdcl79ol8u0beli4\ProjectScript and remove the cache.properties.lock file. 2) Go 到.gradle\caches\2.0\scripts\build_7l4t45nbnsvdcl79ol8u0beli4\ProjectScript并删除 cache.properties.lock 文件。 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如果你在 windows 上试试这个: 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:编辑2:

You can downgrade from your Java 13 to Java 8. It may solve your problems.您可以从 Java 13 降级到 Java 8。它可能会解决您的问题。 However, if you are unwilling to downgrade go to build.gradle and do the following:但是,如果您不愿意将 go 降级为build.gradle ,请执行以下操作:

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请在 windows 或 mac 路径环境中添加您的 skds 路径

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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