Run
- 首先用android studio打开,
- 启动模拟
- react-native run-android
FAQ
SDK location not found
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
解决方案:在react native项目中的android文件夹下新建local.properties,然后添加
sdk.dir = <sdk_install_dir>
例如:sdk.dir = /Users/luckytien/Library/Android/sdk
/bin/sh: adb: command not found
在zsh下面出现/bin/sh: adb: command not found
vim .zshrc
User configuration下面添加 source ~/.bash_profile
使zsh生效
source ~/.bash_profile
No connected devices
com.android.builder.testing.api.DeviceException: No connected devices!
解决方案:需要创建虚拟设备,在android studio的 "Your Virtual Devices"
No online devices found
com.android.builder.testing.api.DeviceException: No online devices found.
模拟器是启动后,但是关机状态
解决方案:点击最右边箭头中的 “cold boot now“
Cannot get property 'taskDependencies' on null object
Gradle sync failed: Cannot get property 'taskDependencies' on null object Consult IDE log for more details
需降低gradle版本,打开项目中 build.gradle
// classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:2.3.3'
Session 'app': Error Installing APK
Application Installation Failed
解决方案:"file"->"preferences"->"Build,Execution,Deployment"->"Instant Run"取消第一项"Enable instant Run to hot swap code/resoure changes on deploy(default enabled)"