@@ -14,67 +14,72 @@ import com.android.build.OutputFile
14
14
* as expected, because the following workaround doesn't apply in that case:
15
15
* https://github.com/facebook/react-native/pull/21408
16
16
*/
17
+
18
+ def bundleInDebug = hasProperty(" bundleInDebug" ) && Boolean . valueOf(property(" bundleInDebug" ))
19
+ def useDevSupport = ! bundleInDebug
20
+
17
21
project. ext. react = [
18
- // The name of the generated asset file containing your JS bundle
19
- // bundleAssetName: "index.android.bundle",
22
+ // The name of the generated asset file containing your JS bundle
23
+ // bundleAssetName: "index.android.bundle",
20
24
21
- // The entry file for bundle generation
22
- // entryFile: "index.android.js",
25
+ // The entry file for bundle generation
26
+ // entryFile: "index.android.js",
23
27
24
- // Whether to bundle JS and assets in debug mode. Set this to false if you want to load
25
- // JavaScript from a bundler, true if you want to embed the bundle in the apk.
26
- bundleInDebug : false ,
28
+ // Whether to bundle JS and assets in debug mode. Set this to false if you want to load
29
+ // JavaScript from a bundler, true if you want to embed the bundle in the apk.
30
+ // Do not change it here; change the property value in gradle.properties instead.
31
+ bundleInDebug : bundleInDebug,
27
32
28
- // Whether to bundle JS and assets in release mode
29
- bundleInRelease : true ,
33
+ // Whether to bundle JS and assets in release mode
34
+ bundleInRelease : true ,
30
35
31
- // Whether to bundle JS and assets in another build variant (if configured).
32
- // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
33
- // The configuration property can be in the following formats
34
- // 'bundleIn${productFlavor}${buildType}'
35
- // 'bundleIn${buildType}'
36
- // bundleInFreeDebug: true,
37
- // bundleInPaidRelease: true,
38
- // bundleInBeta: true,
36
+ // Whether to bundle JS and assets in another build variant (if configured).
37
+ // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
38
+ // The configuration property can be in the following formats
39
+ // 'bundleIn${productFlavor}${buildType}'
40
+ // 'bundleIn${buildType}'
41
+ // bundleInBeta: true,
39
42
40
- // The root of your project, i.e. where "package.json" lives
41
- // root: "../../",
43
+ // The root of your project, i.e. where "package.json" lives
44
+ // root: "../../",
42
45
43
- // Where to put the JS bundle asset in debug mode
44
- // jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
46
+ // Where to put the JS bundle asset in debug mode
47
+ // jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
45
48
46
- // Where to put the JS bundle asset in release mode
47
- // jsBundleDirRelease: "$buildDir/intermediates/assets/release",
49
+ // Where to put the JS bundle asset in release mode
50
+ // jsBundleDirRelease: "$buildDir/intermediates/assets/release",
48
51
49
- // Where to put drawable resources / React Native assets, e.g. the ones you use via
50
- // require('./image.png')), in debug mode
51
- // resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
52
+ // Where to put drawable resources / React Native assets, e.g. the ones you use via
53
+ // require('./image.png')), in debug mode
54
+ // resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
52
55
53
- // Where to put drawable resources / React Native assets, e.g. the ones you use via
54
- // require('./image.png')), in release mode
55
- // resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
56
+ // Where to put drawable resources / React Native assets, e.g. the ones you use via
57
+ // require('./image.png')), in release mode
58
+ // resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
56
59
57
- // By default the gradle tasks are skipped if none of the JS files or assets change; this means
58
- // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
59
- // date; if you have any other folders that you want to ignore for performance reasons (gradle
60
- // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
61
- // for example, you might want to remove it from here.
62
- // inputExcludes: ["android/**", "ios/**"],
60
+ // By default the gradle tasks are skipped if none of the JS files or assets change; this means
61
+ // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
62
+ // date; if you have any other folders that you want to ignore for performance reasons (gradle
63
+ // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
64
+ // for example, you might want to remove it from here.
65
+ // inputExcludes: ["android/**", "ios/**"],
63
66
64
- // Override which node gets called and with what additional arguments
65
- // nodeExecutableAndArgs: ["node"],
67
+ // Override which node gets called and with what additional arguments
68
+ // nodeExecutableAndArgs: ["node"],
66
69
67
- // Supply additional arguments to the packager
68
- // extraPackagerArgs: []
70
+ // Supply additional arguments to the packager
71
+ // extraPackagerArgs: []
69
72
]
70
73
71
74
apply from : " ../../node_modules/react-native/react.gradle"
72
75
73
76
/**
74
- * Set this to true to create two separate APKs instead of one:
75
- * - An APK that only works on ARM devices
76
- * - An APK that only works on x86 devices
77
- * The advantage is the size of the APK is reduced by about 4MB.
77
+ * Set this to true to create separate APKs instead of one:
78
+ * - An APK that only works on 32-bit ARM devices
79
+ * - An APK that only works on 64-bit ARM devices
80
+ * - An APK that only works on 32-bit x86 devices
81
+ * - An APK that only works on 64-bit x86 devices
82
+ * This reduces the size of the APK.
78
83
* Upload all the APKs to the Play Store and people will download
79
84
* the correct one based on the CPU architecture of their device.
80
85
*/
@@ -89,13 +94,14 @@ android {
89
94
compileSdkVersion 28
90
95
91
96
defaultConfig {
92
- applicationId " com.demo.activity"
97
+ applicationId ' com.demo.activity'
93
98
minSdkVersion 23
99
+ compileSdkVersion 28
94
100
targetSdkVersion 28
95
- versionCode 4
96
- versionName " 2.2 "
101
+ versionCode 5
102
+ versionName " 5.0 "
97
103
ndk {
98
- abiFilters ' armeabi-v7a' , ' x86'
104
+ abiFilters ' armeabi-v7a' , ' arm64-v8a ' , ' x86' , ' x86_64 '
99
105
}
100
106
}
101
107
@@ -104,14 +110,18 @@ android {
104
110
reset()
105
111
enable enableSeparateBuildPerCPUArchitecture
106
112
universalApk false // If true, also generate a universal APK
107
- include ' armeabi-v7a' , ' x86'
113
+ include ' armeabi-v7a' , ' arm64-v8a ' , ' x86' , ' x86_64 '
108
114
}
109
115
}
110
116
111
117
buildTypes {
118
+ debug {
119
+ buildConfigField ' boolean' , ' USE_DEVELOPER_SUPPORT' , " $useDevSupport "
120
+ }
112
121
release {
113
122
minifyEnabled enableProguardInReleaseBuilds
114
- proguardFiles getDefaultProguardFile(" proguard-android.txt" ), " proguard-rules.pro"
123
+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
124
+ buildConfigField ' boolean' , ' USE_DEVELOPER_SUPPORT' , ' false'
115
125
}
116
126
}
117
127
@@ -120,20 +130,34 @@ android {
120
130
variant. outputs. each { output ->
121
131
// For each separate APK per architecture, set a unique version code as described here:
122
132
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
123
- def versionCodes = [" armeabi-v7a" : 1 , " x86 " : 2 ]
133
+ def versionCodes = [' armeabi-v7a' : 1 , ' arm64-v8a ' : 2 , ' x86 ' : 3 , ' x86_64 ' : 4 ]
124
134
def abi = output. getFilter(OutputFile . ABI )
125
135
if (abi != null ) { // null for the universal-debug, universal-release variants
126
136
output. versionCodeOverride =
127
137
versionCodes. get(abi) * 1048576 + defaultConfig. versionCode
128
138
}
129
139
}
130
140
}
141
+
142
+ // This is necessary to include the JavaScript bundle in the APK:
143
+ sourceSets {
144
+ main {
145
+ debug {
146
+ if (bundleInDebug) {
147
+ assets. srcDirs + = " $buildDir /intermediates/assets/debug"
148
+ }
149
+ }
150
+ release {
151
+ assets. srcDirs + = " $buildDir /intermediates/assets/release"
152
+ }
153
+ }
154
+ }
131
155
}
132
156
133
157
dependencies {
134
- implementation fileTree(dir : " libs" , include : [" *.jar" ])
158
+ implementation fileTree(dir : ' libs' , include : [' *.jar' ])
135
159
implementation ' com.android.support:appcompat-v7:28.0.0'
136
- implementation(' com.facebook.react:react-native:0.58.6 ' ) {
160
+ implementation(' com.facebook.react:react-native:0.59.9 ' ) {
137
161
exclude group : ' com.android.support'
138
162
}
139
163
}
0 commit comments