11apply plugin : " com.android.application"
22
3+ import com.android.build.OutputFile
4+
35/**
4- * The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
6+ * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+ * and bundleReleaseJsAndAssets).
58 * These basically call `react-native bundle` with the correct arguments during the Android build
69 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
710 * bundle directly from the development server. Below you can see all the possible configurations
@@ -21,6 +24,15 @@ apply plugin: "com.android.application"
2124 * // whether to bundle JS and assets in release mode
2225 * bundleInRelease: true,
2326 *
27+ * // whether to bundle JS and assets in another build variant (if configured).
28+ * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29+ * // The configuration property can be in the following formats
30+ * // 'bundleIn${productFlavor}${buildType}'
31+ * // 'bundleIn${buildType}'
32+ * // bundleInFreeDebug: true,
33+ * // bundleInPaidRelease: true,
34+ * // bundleInBeta: true,
35+ *
2436 * // the root of your project, i.e. where "package.json" lives
2537 * root: "../../",
2638 *
@@ -49,6 +61,21 @@ apply plugin: "com.android.application"
4961
5062apply from : " react.gradle"
5163
64+ /**
65+ * Set this to true to create two separate APKs instead of one:
66+ * - An APK that only works on ARM devices
67+ * - An APK that only works on x86 devices
68+ * The advantage is the size of the APK is reduced by about 4MB.
69+ * Upload all the APKs to the Play Store and people will download
70+ * the correct one based on the CPU architecture of their device.
71+ */
72+ def enableSeparateBuildPerCPUArchitecture = false
73+
74+ /**
75+ * Run Proguard to shrink the Java bytecode in release builds.
76+ */
77+ def enableProguardInReleaseBuilds = false
78+
5279android {
5380 compileSdkVersion 23
5481 buildToolsVersion " 23.0.1"
@@ -63,16 +90,37 @@ android {
6390 abiFilters " armeabi-v7a" , " x86"
6491 }
6592 }
93+ splits {
94+ abi {
95+ reset()
96+ enable enableSeparateBuildPerCPUArchitecture
97+ universalApk false // If true, also generate a universal APK
98+ include " armeabi-v7a" , " x86"
99+ }
100+ }
66101 buildTypes {
67102 release {
68- minifyEnabled false // Set this to true to enable Proguard
103+ minifyEnabled enableProguardInReleaseBuilds
69104 proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
70105 }
71106 }
107+ // applicationVariants are e.g. debug, release
108+ applicationVariants. all { variant ->
109+ variant. outputs. each { output ->
110+ // For each separate APK per architecture, set a unique version code as described here:
111+ // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
112+ def versionCodes = [" armeabi-v7a" :1 , " x86" :2 ]
113+ def abi = output. getFilter(OutputFile . ABI )
114+ if (abi != null ) { // null for the universal-debug, universal-release variants
115+ output. versionCodeOverride =
116+ versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
117+ }
118+ }
119+ }
72120}
73121
74122dependencies {
75123 compile fileTree(dir : " libs" , include : [" *.jar" ])
76124 compile " com.android.support:appcompat-v7:23.0.1"
77- compile " com.facebook.react:react-native:0.18.+ "
125+ compile " com.facebook.react:react-native:+ " // From node_modules
78126}
0 commit comments