Merge pull request #4403 from satya164/docs
[Android] Add docs on building from source
This commit is contained in:
commit
63cff1abcb
|
@ -0,0 +1,106 @@
|
|||
---
|
||||
id: android-building-from-source
|
||||
title: Building React Native from source
|
||||
layout: docs
|
||||
category: Guides (Android)
|
||||
permalink: docs/android-building-from-source
|
||||
next: activityindicatorios
|
||||
---
|
||||
|
||||
You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Assuming you have the Android SDK installed, run `android` to open the Android SDK Manager.
|
||||
|
||||
Make sure you have the following installed:
|
||||
|
||||
1. Android SDK version 23 (compileSdkVersion in [`build.gradle`](https://github.com/facebook/react-native/blob/master/ReactAndroid/build.gradle))
|
||||
2. SDK build tools version 23.0.1 (buildToolsVersion in [`build.gradle`](https://github.com/facebook/react-native/blob/master/ReactAndroid/build.gradle)])
|
||||
3. Android Support Repository >= 17 (for Android Support Library)
|
||||
4. Android NDK (download & extraction instructions [here](http://developer.android.com/ndk/downloads/index.html))
|
||||
|
||||
Point Gradle to your Android SDK: either have `$ANDROID_SDK` and `$ANDROID_NDK ` defined, or create a local.properties file in the root of your react-native checkout with the following contents:
|
||||
|
||||
```
|
||||
sdk.dir=absolute_path_to_android_sdk
|
||||
ndk.dir=absolute_path_to_android_ndk
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
sdk.dir=/Users/your_unix_name/android-sdk-macosx
|
||||
ndk.dir=/Users/your_unix_name/android-ndk/android-ndk-r10e
|
||||
```
|
||||
|
||||
|
||||
## Building the source
|
||||
|
||||
1. Install `react-native` from your fork. For example, to install the master branch from the offcial repo, run the following:
|
||||
|
||||
```sh
|
||||
npm install --save github:facebook/react-native#master
|
||||
```
|
||||
|
||||
Alternatively, you can clone the repo to your `node_modules` directory and run `npm install` inside the cloned repo.
|
||||
|
||||
2. Add `gradle-download-task` as dependency in `andoid/build.gradle`:
|
||||
|
||||
```gradle
|
||||
...
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.3.1'
|
||||
classpath 'de.undercouch:gradle-download-task:2.0.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
3. Add the `:ReactAndroid` project in `andoid/settings.gradle`:
|
||||
|
||||
```gradle
|
||||
...
|
||||
include ':ReactAndroid'
|
||||
|
||||
project(':ReactAndroid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native/ReactAndroid')
|
||||
...
|
||||
```
|
||||
|
||||
4. Modify your `android/app/build.gradle` to use the `:ReactAndroid` project instead of the pre-compiled library, e.g. - replace `compile 'com.facebook.react:react-native:0.16.+'` with `compile project(':ReactAndroid')`:
|
||||
|
||||
```gradle
|
||||
...
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
|
||||
compile project(':ReactAndroid')
|
||||
|
||||
...
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
5. If you use 3rd-party React Native modules, modify your `android/app/build.gradle` to override their dependencies so that they don't bundle the pre-compiled library, e.g. - replace `compile project(':react-native-custom-module')` with:
|
||||
|
||||
```gradle
|
||||
compile(project(':react-native-custom-module')) {
|
||||
exclude group: 'com.facebook.react', module: 'react-native'
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Additional notes
|
||||
|
||||
Building from source can take a long time, especially for the first build, as it needs to download ~200 MB of files and compile JSC etc. Every time you update the `react-native` version from your repo, the build directory may get deleted, and all the files are re-downloaded. To avoid this, you might want to change your build directory path by editing the `~/.gradle/init.gradle ` file:
|
||||
|
||||
```gradle
|
||||
gradle.projectsLoaded {
|
||||
rootProject.allprojects {
|
||||
buildDir = "/path/to/build/directory/${rootProject.name}/${project.name}"
|
||||
}
|
||||
}
|
||||
```
|
|
@ -4,7 +4,7 @@ title: Profiling Android UI Performance
|
|||
layout: docs
|
||||
category: Guides (Android)
|
||||
permalink: docs/android-ui-performance.html
|
||||
next: activityindicatorios
|
||||
next: android-building-from-source
|
||||
---
|
||||
|
||||
We try our best to deliver buttery-smooth UI performance by default, but sometimes that just isn't possible. Remember, Android supports 10k+ different phones and is generalized to support software rendering: the framework architecture and need to generalize across many hardware targets unfortunately means you get less for free relative to iOS. But sometimes, there are things you can improve (and many times it's not native code's fault at all!).
|
||||
|
@ -12,7 +12,7 @@ We try our best to deliver buttery-smooth UI performance by default, but sometim
|
|||
The first step for debugging this jank is to answer the fundamental question of where your time is being spent during each 16ms frame. For that, we'll be using a standard Android profiling tool called systrace. But first...
|
||||
|
||||
> Make sure that JS dev mode is OFF!
|
||||
>
|
||||
>
|
||||
> You should see `__DEV__ === false, development-level warning are OFF, performance optimizations are ON` in your application logs (which you can view using `adb logcat`)
|
||||
|
||||
## Profiling with Systrace
|
||||
|
|
Loading…
Reference in New Issue