react-native构建android hello world踩坑记

来源:互联网 发布:python 多行字符串 编辑:程序博客网 时间:2024/05/21 01:54

写在前面: 纯小白,记录自己踩过的坑

  1. 我傻我承认,有node环境的情况下又装了一遍node导致系统中有2个node版本 卒。。。。
    解决方案 :重装nvm。。。辣么傻。。。
  2. 然后create-react-native-app新建项目报错
    原因:项目中设置项目 npm set registry=http://registry.npm.mycompany/,这样设置会报错,,我也不知道为啥。。
    解决方案:重新设置镜像源 npm set registry https://registry.npm.taobao.org/
  3. adb devices连不上设备(魅族)
    解决方案:查看硬件id 然后在 /.androidl里面新建adb_usb.ini的配置文件,内容为adb 的6位硬件id
  4. adb无法使用,提示unknown host service
    原因:5037端口被占用
    解决方案:
    ● 打开命令行,输入命令:netstat -ano |findstr “5037”
    ● 查看到对应的进程的PID
    ● Ctrl+alt+delete,打开任务管理器,查看是哪个进程占用了PID,结束该进程
  5. react-native run-android时报错:
    You have not accepted the license agreements of the following SDK components:[Android SDK Platform 23, Android SDK Build-Tools 23.0.1].
    解决:android studio版本已经超过23,所以必须在platform和sdk tools中把23版本加上。在SDK Platforms窗口中,选择Show Package Details,然后在Android 6.0 (Marshmallow)中勾选Google APIs、Android SDK Platform 23、Intel x86 Atom System Image、Intel x86 Atom_64 System Image以及Google APIs Intel x86 Atom_64 System Image。
    在SDK Tools窗口中,选择Show Package Details,然后在Android SDK Build Tools中勾选Android SDK Build-Tools 23.0.1(必须是这个版本)。然后还要勾选最底部的Android Support Repository.

构建失败之后要清缓存,,,
cd android && gradlew clean
cd ../ && react-native run-android

原创粉丝点击