react -native Android真机调试注意的问题

来源:互联网 发布:什么是行知教育思想 编辑:程序博客网 时间:2024/06/06 14:17

1.用Android studio把ipk运行到真机上面去。

2.再用vscode把项目打开,再把服务用npm启动起来

(1).用vscode的终端输入:npm start 

(2).出现端口占用情况

 Looking for JS files in

   /Users/xiangcaihua/Desktop/ClaimPlatform
 ERROR  Packager can't listen on port 8081
Most likely another process is already using this port
Run the following command to find out which process:
   lsof -i :8081
Then, you can either shut down the other process:
   kill -9 <PID>
or run packager on different port.
Loading dependency graph...npm ERR! code ELIFECYCLE
npm ERR! errno 11
npm ERR! ClaimPlatform@0.0.1 start: `node node_modules/react-native/local-cli/cli.js start`
npm ERR! Exit status 11
npm ERR!
npm ERR! Failed at the ClaimPlatform@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.3.0 → 5.5.1    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xiangcaihua/.npm/_logs/2017-11-18T09_02_35_916Z-debug.log

(3)输入lsof -i :8081

       COMMAND  PID        USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
       node    4773 xiangcaihua   36u  IPv6 0x4ccbef72e2aeecdb      0t0  TCP *:sunproxyadmin (LISTEN)
       kill node    4773 xiangcaihua   42u  IPv6 0x4ccbef72d626775b      0t0  TCP 172.20.10.7:sunproxyadmin->172.20.10.

(4)输入 kill -9  4773把node那个服务kill掉

(5)然后再npm start

3 .在真机上进行设置Dev setting 设置端口,ip地址为你电脑的地址,端口号一般为:8081

4. 确保手机和电脑在同一个网段。

5.reload完成Mac电脑调试到真机的全过程,以及注意事项为:确保在同一网段





原创粉丝点击