|
|
@@ -184,6 +184,47 @@ ext {
|
|
184
|
184
|
moduleGroupId = 'com.facebook.react'
|
|
185
|
185
|
}
|
|
186
|
186
|
|
|
|
187
|
+// If Android SDK is not installed, accept its license so that it
|
|
|
188
|
+// is automatically downloaded.
|
|
|
189
|
+afterEvaluate { project ->
|
|
|
190
|
+ // Either the environment variable ANDROID_HOME or the property sdk.dir in
|
|
|
191
|
+ // local.properties identifies where Android SDK is installed.
|
|
|
192
|
+ def androidHome = System.env.ANDROID_HOME
|
|
|
193
|
+ if (!androidHome) {
|
|
|
194
|
+ // ANDROID_HOME is not set. Is sdk.dir set?
|
|
|
195
|
+ def file = file("${project.rootDir}/local.properties")
|
|
|
196
|
+ def props = new Properties()
|
|
|
197
|
+ if (file.canRead()) {
|
|
|
198
|
+ file.withInputStream {
|
|
|
199
|
+ props.load(it)
|
|
|
200
|
+ androidHome = props.'sdk.dir'
|
|
|
201
|
+ }
|
|
|
202
|
+ }
|
|
|
203
|
+ if (!androidHome && (!file.exists() || file.canWrite())) {
|
|
|
204
|
+ // Neither ANDROID_HOME nor sdk.dir is set. Set sdk.dir (because
|
|
|
205
|
+ // environment variables cannot be set).
|
|
|
206
|
+ props.'sdk.dir' = "${project.buildDir}/android-sdk".toString()
|
|
|
207
|
+ file.withOutputStream {
|
|
|
208
|
+ props.store(it, null)
|
|
|
209
|
+ androidHome = props.'sdk.dir'
|
|
|
210
|
+ }
|
|
|
211
|
+ }
|
|
|
212
|
+ }
|
|
|
213
|
+ // If the license is not accepted, accept it so that automatic downloading
|
|
|
214
|
+ // kicks in.
|
|
|
215
|
+ if (androidHome) {
|
|
|
216
|
+ def dir = file("${androidHome}/licenses")
|
|
|
217
|
+ dir.mkdirs()
|
|
|
218
|
+ def file = file("${dir.path}/android-sdk-license")
|
|
|
219
|
+ if (!file.exists()) {
|
|
|
220
|
+ file.withWriter {
|
|
|
221
|
+ def hash = 'd56f5187479451eabf01fb78af6dfcb131a6481e'
|
|
|
222
|
+ it.write(hash, 0, hash.length())
|
|
|
223
|
+ }
|
|
|
224
|
+ }
|
|
|
225
|
+ }
|
|
|
226
|
+}
|
|
|
227
|
+
|
|
187
|
228
|
// Force the version of the Android build tools we have chosen on all
|
|
188
|
229
|
// subprojects. The forcing was introduced for react-native and the third-party
|
|
189
|
230
|
// modules that we utilize such as react-native-background-timer.
|