ReactNative Could not install the app on the device(Mac OS环境)

我们从github下载的ReactNative(以下简称RN)经常会出现这个错误:

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/android-setup.html

导致构建失败BUILD FAILED.

看到上述的命令行提示,发现他的意思是我们的安卓环境可能配置的不对,还让我们去官网看看,那好吧,咱们到官网一看,有个步骤是这样的

Set up paths 

The React Native command line interface requires the ANDROID_HOME environment variable to be set up. You can configure it in a Terminal using the following command:

export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_HOME=~/Library/Android/sdkexport PATH=${PATH}:${ANDROID_HOME}/tools

To avoid doing this every time you open a new Terminal, create (or edit) ~/.bashrc using your favorite text editor and add the following lines:

The second line will add the android tool to your path, which will come in handy in the next step.

Please make sure you export the correct path for ANDROID_HOME if you did not install the Android SDK using Android Studio. If you install the Android SDK using Homebrew, it will be located at /usr/local/opt/android-sdk.


这个是环境相关的配置,咱们只需要这样在命令行中输入:export ANDORD_HOME = 我们的android sdk 路径(一个细节后面记得加上 sdk,这个目录才是sdk的位置,否则还是会报错,我就是忘记加这个了)

然后上面设置完成后设置到环境变量PATH中即可

export PATH = ${PATH}:${ANDROID_HOME}/tools

上述配置完成后,react-native run-android 继续运行,这个时候他会构建运行该项目的必需project,我们等待即可,这个时候如果gradle 是1.3.1,命令行中可能会出现以下错误:

com.android.ddmlib.InstallException: Unable to upload some APKs

 需要将project的gradle version修改到1.2.3,可能这个版本命令行启动不了


http://blog.csdn.net/shenshibaoma/article/details/52936349 可以看下我这篇博客的介绍,有说到这个错误。



评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值