简体   繁体   English

即使我在后台运行了模拟器,也无法运行我的React本机代码

[英]I can't run my react native code even though I have an emulator running in the back round

I am trying to run react native code but when I use react-native run-android I get this error message. 我正在尝试运行React本机代码,但是当我使用react-native run-android时,出现此错误消息。 I am using android studio. 我正在使用android studio。

~/Downloads/BrainG-master$ sudo react-native run-android

Scanning folders for symlinks in /home/luke/Downloads/BrainG-
master/node_modules (10ms)

JS server already running.

Building and installing the app on the device (cd android && ./gradlew 
installDebug)...

: No such file or directory

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:

Make sure 确保

  1. there is an android directory inside /Downloads/BrainG-master (I hope you're not running react-native run-android from within the android directory) and /Downloads/BrainG-master有一个android目录(我希望您不要从android目录中运行react-native run-android ),

  2. your local.properties file in BrainG-master/android has the location of your android SDK specified in the following format: sdk.dir=/Users/username/pathToYourAndroidSdk . BrainG-master/android中的local.properties文件以以下格式指定了android SDK的位置: sdk.dir=/Users/username/pathToYourAndroidSdk

If there is no local.properties file, open the project in Android Studio and it will create that for you. 如果没有local.properties文件,请在Android Studio中打开该项目,它将为您创建该项目。

If you're on Linux, you can also configure the android home environment thus: 如果您使用的是Linux,则还可以这样配置android家庭环境:

Add the following lines to your $HOME/.bash_profile config file: 将以下行添加到$ HOME / .bash_profile配置文件中:

export ANDROID_HOME=$HOME/Android/Sdk

export PATH=$PATH:$ANDROID_HOME/tools

export PATH=$PATH:$ANDROID_HOME/platform-tools

.bash_profile is specific to bash . .bash_profile特定于bash If you're using another shell, you will need to edit the appropriate shell-specific config file. 如果您使用的是其他外壳,则需要编辑相应的特定于外壳的配置文件。

Type source $HOME/.bash_profile to load the config into your current shell. 键入source $HOME/.bash_profile以将配置加载到当前的shell中。 Verify that ANDROID_HOME has been added to your path by running echo $PATH . 通过运行echo $PATH验证是否已将ANDROID_HOME添加到您的路径。

You can follow the instructions here: https://facebook.github.io/react-native/docs/getting-started.html#2-install-the-android-sdk 您可以按照以下说明进行操作: https : //facebook.github.io/react-native/docs/getting-started.html#2-install-the-android-sdk

暂无
暂无

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

相关问题 为什么即使我已将数字转换回字符串,我也不能将数字推送到我的字符串数组中? - Why can I not push a number into my array of strings even though I have converted the number back to a string? 为什么我的setInterval循环在退出前又要经过一轮,即使我一开始就终止了 - Why does my setInterval loop go another round before exiting even though I have the termination in the beginning 为什么我不能运行我的React Native项目? - Why can't I run my React Native project? 即使我的代码看起来很好,我仍然会收到“未捕获的TypeError:字符串不是函数”错误。任何人都可以看看并解释一下吗? - I keep getting a “Uncaught TypeError: string is not a function” error, even though my code seems to be fine. Can anyone have a look and explain? 即使我的代码中有catch部分,我仍收到未处理的Promise Rejection错误 - I am getting Unhandled Promise Rejection error even though I have the catch section in my code 这是一个反应本机项目。 我的编译器发现 item 变量未定义,即使我在 function 中使用了 item - This is a react native project. My compiler finds the item variable to be undefined even though I used item in a function 即使我有库,我的动画代码也无法在 Visual Studio Code 中运行 - My anime code is not working in Visual Studio Code even though I have the library 我必须制作一个可以运行一些简单JavaScript的网页,但是我认为我的脚本没有运行 - I have to make a webpage that can run some simple JavaScript, but I don't think my script is running 我如何知道我的代码是否作为 React Native 运行 - How do I know if my code is running as React Native 即使我在本地服务器上运行我的代码,也会出现“无法加载模块脚本...” - Getting "Failed to load module script..." even though I run my code on a local server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM