繁体   English   中英

无法在react-native run-android上的设备上安装应用程序

[英]Could not install the app on the device on react-native run-android

我无法运行任何反应本机项目。 它说已经有一个进程在运行。 端口8081由我的MAC上运行的McAfee防病毒软件占用。 并且我决不能杀死它(即使我不应该杀死它,我试过它,看起来它永远不会死!SUDO毕竟没有力量!)

参考#7308 #9145stackoverflow ,我试图在端口8082上运行。服务器启动,但是, 运行android仍然无法说没有找到设备。 我有我的设备(启用调试模式的Galaxy S7 Edge)和Genymotion打开。

React Native版本详细信息 -

SATJAGAN-M-T0HZ:react-native-card-modal satjagan$ react-native -v
react-native-cli: 1.0.0
react-native: 0.37.0

Genymotion活跃且可用 -

bozzmob:Twitter bozzmobusr$ adb devices
List of devices attached
192.168.57.101:5555 device

运行应用程序的终端日志 - (有趣的是它说JS服务器无法识别 ,那里有任何问题)?

bozzmob:Twitter bozzmobusr$ react-native start --port 8082
Scanning 712 folders for symlinks in /Users/satjagan/collection/work/github/reactnative/react-native-card-modal/node_modules (15ms)
 ┌────────────────────────────────────────────────────────────────────────────┐ 
 │  Running packager on port 8082.                                            │ 
 │                                                                            │ 
 │  Keep this packager running while developing on any JS projects. Feel      │ 
 │  free to close this tab and run your own packager instance if you          │ 
 │  prefer.                                                                   │ 
 │                                                                            │ 
 │  https://github.com/facebook/react-native                                  │ 
 │                                                                            │ 
 └────────────────────────────────────────────────────────────────────────────┘ 
Looking for JS files in
   /Users/satjagan/collection/work/github/reactnative/react-native-card-modal 

[Hot Module Replacement] Server listening on /hot

React packager ready.

[11/26/2016, 2:47:25 PM] <START> Initializing Packager
[11/26/2016, 2:47:25 PM] <START> Building in-memory fs for JavaScript
[11/26/2016, 2:47:25 PM] <END>   Building in-memory fs for JavaScript (184ms)
[11/26/2016, 2:47:25 PM] <START> Building Haste Map
[11/26/2016, 2:47:25 PM] <END>   Building Haste Map (425ms)
[11/26/2016, 2:47:25 PM] <END>   Initializing Packager (741ms)



bozzmob:Twitter bozzmobusr$ react-native run-android
**JS server not recognized, continuing with build...**
Running adb -s 192.168.57.101:5555 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug...
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.
Go to https://facebook.github.io/react-native/docs/getting-started.html
and check the Android tab for setup instructions.

不幸的是卸载迈克菲不是一个选择:(如果我有自由,我会先做它。

React-Native仍在尝试连接8081.上的打包器。通常你打开开发菜单并指定一个不同的端口,但在你的情况下你甚至无法开始。

否则您似乎无法指定端口。 我想你可能有两种选择:

  1. 暂时通过开发菜单杀死McAfee,安装和更改端口,如下所述: https//facebook.github.io/react-native/docs/troubleshooting.html#terminating-a-process-on-port-8081

  2. 更改此文件: https//github.com/facebook/react-native/blob/292cc82d0ebc437a6f1cdd2e972b3917b7ee05a4/Libraries/Core/Devtools/getDevServer.js

我有类似的问题。 我无法通过kill命令停止McAfee进程。 这是因为它作为服务运行。 然而,它可以通过lanuchctl工具停止。 尝试这个:

cd /Library/LaunchDaemons sudo launchctl unload com.mcafee.agent.macmn.plist

它将阻止采用8081端口的迈克菲进程。

以下是指定非默认包装程序位置应执行的操作:

(物理抖动设备)>开发设置>调试服务器主机和设备端口> IP:端口

在此输入图像描述

笔记:

  • 显然,这需要首先在设备上安装应用程序。 如果您无法自动执行此操作,只需将创建的.apk手动复制到设备上,然后在安装后继续执行说明。
  • AFAIK,在撰写本文时,此选项在iOS版本的 react-native中不可用
  • 要在模拟器上打开调试菜单,您可以使用陀螺仪/加速度计滑块来模拟摇动(我在Windows上的库存模拟器上测试它,而不是GenyMotion)。 也许有一种更容易的方法,但我还没找到一个。

我几乎在所有情况下都知道应用程序应该使用您当前的项目设置和代码运行,如果它不起作用,请尝试:

killall -9 node

因为Metro Bundler节点进程可能存在问题。 有时会变得紧张起来。

这就是我所做的,但你可以更具体地看看哪些进程持有端口8081并杀死它们。 (尝试像sudo lsof -n -i4TCP:8081这样的sudo lsof -n -i4TCP:8081 (引用: lsof定义 )。如果你在localhost上运行一些node.js API,你应该更加小心杀死所有节点进程,但如果你只是做React Native dev,你可以安全地做到这一点。

暂无
暂无

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

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