Chocolatey是一个Windows上的包管理器 官方网站 需要以管理员的身份来运行命令提示符窗口,然后执行
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
如果找不到powershells可以在C盘里搜索一下
打开命令提示符窗口,使用Chocolatey来安装Python 2
choco install python2
打开命令提示符窗口,使用Chocolatey来安装NodeJS
choco install nodejs.install
eact Native的命令行工具用于执行创建、初始化、更新项目、运行打包服务(packager)等任务。
npm install -g react-native-cli
如果你遇到EACCES: permission denied权限错误,可以尝试运行下面的命令: sudo npm install -g react-native-cli
choco install git
比起Android Studio自带的原装模拟器,Genymotion是一个性能更好的选择,但它只对个人用户免费 genymotion
Visual Studio Emulator for Android)是利用了Hyper-V技术进行硬件加速的免费android模拟器。也是Android Studio自带的原装模拟器之外的一个很好的选择。而且你并不需要安装Visual Studio。 Emulator
choco install jdk8
确保ANDROID_HOME环境变量正确地指向了你安装的Android SDK的路径
将Android SDK的Tools目录添加到PATH变量中
开启Gradle Daemon可以极大地提升java代码的增量编译速度
(if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo org.gradle.daemon=true >> "%USERPROFILE%/.gradle/gradle.properties")
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
react-native init awesome
ReferenceError: [BABEL] E:\rn\AwesomeProject\node_modules\react-native\local-cli
\cliEntry.js: Unknown option: base.directory.
这个问题出现了使用了最新版的node自带的npm@3的情况 请使用node稳定版4.4.7
react-native init awesome
Error: Cannot find module 'babel-plugin-transform-es2015-template-literals'
解决Genymotion出现Unable to load VirtualBox engin
启动 VirtualBox报到 创建失败(被召者 RC: REGDB_E_CLASSNOTREG (0x80040154)) 不要用最新版本,使用VirutalBox4.3.12 VirutalBox
Execution failed for task ':app:processDebugResources' 查看编译错误
cd android
gradlew.bat --info clean build
A problem occurred configuring project ':app'.
> failed to find Build Tools revision 23.0.1
打开 sdk manager 安装 Build Tools 23.0.1
http://stackoverflow.com/questions/21645961/android-studio-processdebugresources-failed
* What went wrong:
Execution failed for task ':app:packageDebug'.
> Failed to read key AndroidDebugKey from store "C:\Users\Administrator\.android\debug.keystore": Invalid keystore format
删除 C:\Users\Administrator.android\debug.keystore
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
在E:\finalrn\android\app\build.gradle
中增加
android {
lintOptions {
abortOnError false
}
}
E:\finalrn\node_modules\react-native\packager>packager.sh start --reset-cache
###
Total time: 21.771 secs
Error: Expected verb after global parameters but found '{' instead.
Usage:
android [global options] action [action options]