Restore Android setup instructions in the Getting Started
Summary: This PR restores some [additional detail](http://facebook.github.io/react-native/releases/0.28/docs/getting-started.html) that was removed from the Android Getting Started this summer. I'm not fully restoring the original list of steps as the React Native website should not be the source of truth for setting up an Android development environment. Closes https://github.com/facebook/react-native/pull/9867 Differential Revision: D3887834 Pulled By: fredemmott fbshipit-source-id: 8e3599f8945ba68f31dc9b0f79c2db7e525e7f45
This commit is contained in:
parent
7dbc8051e5
commit
d41c3950eb
|
@ -64,95 +64,220 @@ block { display: none; }
|
|||
|
||||
<!-- ######### MAC for iOS ##################### -->
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
## Installing Dependencies
|
||||
|
||||
<block class="mac ios" />
|
||||
|
||||
## Dependencies for Mac + iOS
|
||||
|
||||
You will need Xcode, node.js, the React Native command line tools, and Watchman.
|
||||
You will need Node.js, Watchman, the React Native command line interface, and Xcode.
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
## Dependencies for Mac + Android
|
||||
|
||||
You will need Android Studio, node.js, the React Native command line tools, and Watchman.
|
||||
You will need Node.js, Watchman, the React Native command line interface, and Android Studio.
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
We recommend installing node and watchman via [Homebrew](http://brew.sh/).
|
||||
### Node, Watchman
|
||||
|
||||
We recommend installing Node and Watchman using [Homebrew](http://brew.sh/). Run the following commands in a Terminal after installing Homebrew:
|
||||
|
||||
```
|
||||
brew install node
|
||||
brew install watchman
|
||||
```
|
||||
|
||||
Node comes with npm, which lets you install the React Native command line interface.
|
||||
> [Watchman](https://facebook.github.io/watchman) is a tool by Facebook for watching
|
||||
changes in the filesystem. It is highly recommended you install it for better performance.
|
||||
|
||||
### The React Native CLI
|
||||
|
||||
Node.js comes with npm, which lets you install the React Native command line interface. Run the following command in a Terminal:
|
||||
|
||||
```
|
||||
npm install -g react-native-cli
|
||||
```
|
||||
|
||||
If you get a permission error, try with sudo: `sudo npm install -g react-native-cli`.
|
||||
> If you get a *permission error*, try using sudo: `sudo npm install -g react-native-cli`.
|
||||
|
||||
If you get error `Cannot find module 'npmlog'`, try this before: `curl -0 -L http://npmjs.org/install.sh | sudo sh`.
|
||||
> If you get an error like `Cannot find module 'npmlog'`, try installing npm directly: `curl -0 -L http://npmjs.org/install.sh | sudo sh`.
|
||||
|
||||
<block class="mac ios" />
|
||||
|
||||
The easiest way to install Xcode is via the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12).
|
||||
### Xcode
|
||||
|
||||
The easiest way to install Xcode is via the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12). Installing Xcode will also install the iOS Simulator and all the necessary tools to build your iOS app.
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
### Android Development Environment
|
||||
|
||||
Setting up your development environment can be somewhat tedious if you're new to Android development. If you're already familiar with Android development, there are a few things you may need to configure. In either case, please make sure to carefully follow the next few steps.
|
||||
|
||||
#### 1. Install Android Studio
|
||||
|
||||
Download and install [Android Studio](https://developer.android.com/studio/install.html).
|
||||
|
||||
If you plan to make changes in Java code, we recommend [Gradle Daemon](https://docs.gradle.org/2.9/userguide/gradle_daemon.html) which speeds up the build.
|
||||
#### 2. Confirm the Android SDK is installed
|
||||
|
||||
Android Studio installs `Android 7.0 (Nougat)` by default. You can confirm that the SDK was installed by clicking on "Configure" in the last screen in the Android Studio Setup Wizard, or by opening "Preferences" from the Android Studio menu, then choosing `Appearance and Behavior` → `System Settings` → `Android SDK`.
|
||||
|
||||
![Android Studio SDK Manager](img/react-native-android-studio-configure-sdk.png)
|
||||
|
||||
Select "SDK Platforms" from within the SDK Manager and you should see a blue checkmark next to "Android 7.0 (Nougat)". In case it is not, click on the checkbox and then "Apply".
|
||||
|
||||
![Android Studio SDK Manager](img/react-native-sdk-platforms.png)
|
||||
|
||||
> If you wish to support older versions of Android, you can install additional Android SDKs from this screen.
|
||||
|
||||
#### 3. 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
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
export ANDROID_HOME=~/Library/Android/sdk
|
||||
export PATH=${PATH}:${ANDROID_HOME}/tools
|
||||
```
|
||||
|
||||
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`.
|
||||
|
||||
#### 4. Set up your Android Virtual Device
|
||||
|
||||
Android Studio should have set up an Android Virtual Device for you during installation, but it is very common to run into an issue where Android Studio fails to install the AVD.
|
||||
|
||||
![Android Studio AVD Manager](img/react-native-tools-avd.png)
|
||||
|
||||
To see the list of available AVDs, launch the "AVD Manager" from within Android Studio or run the following command in a Terminal:
|
||||
|
||||
```
|
||||
android avd
|
||||
```
|
||||
|
||||
You may follow the [Android Studio User Guide](https://developer.android.com/studio/run/managing-avds.html) to create a new AVD if needed.
|
||||
|
||||
> If you see "No system images installed for this target." under CPU/ABI, go back to your "SDK Manager" and click on "Show Package Details" under "SDK Platforms". You will then be able to install any missing system images, such as "Google APIs Intel Atom (x86)".
|
||||
|
||||
<!-- ######### LINUX and WINDOWS for ANDROID ##################### -->
|
||||
|
||||
<block class="linux android" />
|
||||
<block class="windows linux android" />
|
||||
|
||||
## Dependencies for Linux + Android
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
## Dependencies for Windows + Android
|
||||
|
||||
<block class="linux windows android" />
|
||||
|
||||
You will need node.js, the React Native command line tools, Watchman, and Android Studio.
|
||||
## Installing Dependencies
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
You will need Node.js, the React Native command line interface, and Android Studio.
|
||||
|
||||
### Node
|
||||
|
||||
Follow the [installation instructions for your Linux distribution](https://nodejs.org/en/download/package-manager/) to install Node.js 4 or newer.
|
||||
|
||||
<block class='windows android' />
|
||||
|
||||
We recommend installing node.js and Python2 via [Chocolatey](https://chocolatey.org), a popular package manager for Windows. Open a Command Prompt as Administrator, then run:
|
||||
You will need Node.js, the React Native command line interface, and Android Studio.
|
||||
|
||||
### Node
|
||||
|
||||
We recommend installing Node.js and Python2 via [Chocolatey](https://chocolatey.org), a popular package manager for Windows. Open a Command Prompt as Administrator, then run:
|
||||
|
||||
```
|
||||
choco install nodejs.install
|
||||
choco install python2
|
||||
```
|
||||
|
||||
> You can find additional installation options on [Node.js's Downloads page](https://nodejs.org/en/download/).
|
||||
|
||||
<block class="windows linux android" />
|
||||
|
||||
### The React Native CLI
|
||||
|
||||
Node comes with npm, which lets you install the React Native command line interface.
|
||||
|
||||
```
|
||||
npm install -g react-native-cli
|
||||
```
|
||||
|
||||
<block class="windows linux android" />
|
||||
### Android Development Environment
|
||||
|
||||
Setting up your development environment can be somewhat tedious if you're new to Android development. If you're already familiar with Android development, there are a few things you may need to configure. In either case, please make sure to carefully follow the next few steps.
|
||||
|
||||
#### 1. Install Android Studio
|
||||
|
||||
Download and install [Android Studio](https://developer.android.com/studio/install.html).
|
||||
|
||||
#### 2. Confirm the Android SDK is installed
|
||||
|
||||
Android Studio installs `Android 7.0 (Nougat)` by default. You can confirm that the SDK was installed by clicking on "Configure" in the last screen in the Android Studio Setup Wizard, or by opening "Preferences" from the Android Studio menu, then choosing `Appearance and Behavior` → `System Settings` → `Android SDK`.
|
||||
|
||||
![Android Studio SDK Manager](img/react-native-android-studio-configure-sdk-windows.png)
|
||||
|
||||
Select "SDK Platforms" from within the SDK Manager and you should see a blue checkmark next to "Android 7.0 (Nougat)". In case it is not, click on the checkbox and then "Apply".
|
||||
|
||||
![Android Studio SDK Manager](img/react-native-sdk-platforms.png)
|
||||
|
||||
> If you wish to support older versions of Android, you can install additional Android SDKs from this screen.
|
||||
|
||||
#### 3. Set up paths
|
||||
|
||||
The React Native command line interface requires the `ANDROID_HOME` environment variable to be set up.
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
[Watchman](https://facebook.github.io/watchman) is a tool by Facebook for watching changes in the filesystem. Installing it should
|
||||
improve performance, but you can also try not installing it, if the installation process is too annoying. You can follow the [Watchman installation guide](https://facebook.github.io/watchman/docs/install.html#installing-from-source) to compile and install from source.
|
||||
Create or edit your `~/.bashrc` file and add the following lines:
|
||||
|
||||
<block class="windows linux android" />
|
||||
```
|
||||
export ANDROID_HOME=~/Android/Sdk
|
||||
export PATH=${PATH}:${ANDROID_HOME}/tools
|
||||
```
|
||||
|
||||
If you plan to make changes in Java code, we recommend [Gradle Daemon](https://docs.gradle.org/2.9/userguide/gradle_daemon.html) which speeds up the build.
|
||||
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.
|
||||
|
||||
<block class="windows android" />
|
||||
|
||||
Go to `Control Panel` → `System and Security` → `System` → `Change settings` →
|
||||
`Advanced System Settings` → `Environment variables` → `New`, then enter the path to your Android SDK.
|
||||
|
||||
![env variable](img/react-native-android-sdk-environment-variable-windows.png)
|
||||
|
||||
> Please make sure you use the correct path for `ANDROID_HOME` if you did not install the Android SDK using Android Studio.
|
||||
|
||||
Restart the Command Prompt to apply the new environment variable.
|
||||
|
||||
<block class="linux windows android" />
|
||||
|
||||
#### 4. Set up your Android Virtual Device
|
||||
|
||||
Android Studio should have set up an Android Virtual Device for you during installation, but it is very common to run into an issue where Android Studio fails to install the AVD.
|
||||
|
||||
![Android Studio AVD Manager](img/react-native-tools-avd.png)
|
||||
|
||||
To see the list of available AVDs, launch the "AVD Manager" from within Android Studio or run the following command in a terminal:
|
||||
|
||||
```
|
||||
android avd
|
||||
```
|
||||
|
||||
You may follow the [Android Studio User Guide](https://developer.android.com/studio/run/managing-avds.html) to create a new AVD if needed.
|
||||
|
||||
> If you see "No system images installed for this target." under CPU/ABI, go back to your "SDK Manager" and click on "Show Package Details" under "SDK Platforms". You will then be able to install any missing system images, such as "Google APIs Intel Atom (x86)".
|
||||
|
||||
<block class="linux android" />
|
||||
|
||||
### Watchman (optional)
|
||||
|
||||
Follow the [Watchman installation guide](https://facebook.github.io/watchman/docs/install.html#build-install) to compile and install Watchman from source.
|
||||
|
||||
> [Watchman](https://facebook.github.io/watchman/docs/install.html) is a tool by Facebook for watching
|
||||
changes in the filesystem. It is highly recommended you install it for better performance, but it's alright to skip this if you find the process to be tedious.
|
||||
|
||||
<block class="mac ios android" />
|
||||
|
||||
|
@ -160,7 +285,7 @@ If you plan to make changes in Java code, we recommend [Gradle Daemon](https://d
|
|||
|
||||
<block class="mac ios" />
|
||||
|
||||
Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run `react-native run-ios` inside the newly created folder.
|
||||
Use the React Native command line interface to generate a new React Native project called "AwesomeProject", then run `react-native run-ios` inside the newly created folder.
|
||||
|
||||
```
|
||||
react-native init AwesomeProject
|
||||
|
@ -168,11 +293,13 @@ cd AwesomeProject
|
|||
react-native run-ios
|
||||
```
|
||||
|
||||
You should see your new app running in the iOS Simulator shortly. `react-native run-ios` is just one way to run your app - you can also run it directly from within Xcode or Nuclide.
|
||||
You should see your new app running in the iOS Simulator shortly.
|
||||
|
||||
`react-native run-ios` is just one way to run your app. You can also run it directly from within Xcode or Nuclide.
|
||||
|
||||
<block class="mac android" />
|
||||
|
||||
Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run `react-native run-android` inside the newly created folder.
|
||||
Use the React Native command line interface to generate a new React Native project called "AwesomeProject", then run `react-native run-android` inside the newly created folder.
|
||||
|
||||
```
|
||||
react-native init AwesomeProject
|
||||
|
@ -210,7 +337,7 @@ Congratulations! You've successfully run and modified your first React Native ap
|
|||
|
||||
## Testing your React Native Installation
|
||||
|
||||
Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run `react-native run-android` inside the newly created folder.
|
||||
Use the React Native command line interface to generate a new React Native project called "AwesomeProject", then run `react-native run-android` inside the newly created folder.
|
||||
|
||||
```
|
||||
react-native init AwesomeProject
|
||||
|
|
|
@ -12,6 +12,10 @@ Sometimes an app needs access to a platform API that React Native doesn't have a
|
|||
|
||||
We designed React Native such that it is possible for you to write real native code and have access to the full power of the platform. This is a more advanced feature and we don't expect it to be part of the usual development process, however it is essential that it exists. If React Native doesn't support a native feature that you need, you should be able to build it yourself.
|
||||
|
||||
### Enable Gradle
|
||||
|
||||
If you plan to make changes in Java code, we recommend enabling [Gradle Daemon](https://docs.gradle.org/2.9/userguide/gradle_daemon.html) to speed up builds.
|
||||
|
||||
## The Toast Module
|
||||
|
||||
This guide will use the [Toast](http://developer.android.com/reference/android/widget/Toast.html) example. Let's say we would like to be able to create a toast message from JavaScript.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 133 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
Loading…
Reference in New Issue