Skip to content

Commit

Permalink
Android: Add support for dynamic buildTools/compileSdk/etc versions
Browse files Browse the repository at this point in the history
The buildTools version can be obtained from `rootProject.ext` on react-native 0.56. This
commit adds support for that and if the variables are not defined falls back to the
versions expected by react-native (on 0.56).

This also adds a way of customizing the fresco library version
used via `rootProject.ext.frescoVersion`.

inspired by: OneSignal/react-native-onesignal#442 (comment)
  • Loading branch information
Jyrno42 committed Aug 21, 2018
1 parent e28f541 commit c623c8f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ buildscript {

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
compileSdkVersion safeExtGet('compileSdkVersion', 26)
buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
versionCode 1
}
lintOptions {
Expand All @@ -34,7 +38,7 @@ repositories {
}

dependencies {
compile 'com.facebook.react:react-native:+'
compile 'com.facebook.fresco:fresco:0.11.0'
compile 'me.relex:photodraweeview:1.0.0'
implementation 'com.facebook.react:react-native:+'
implementation "com.facebook.fresco:fresco:${safeExtGet('frescoVersion', '0.11.0')}"
implementation 'me.relex:photodraweeview:1.0.0'
}

0 comments on commit c623c8f

Please sign in to comment.