Skip to content

Commit 4258da9

Browse files
author
Ali Abdelfattah
authored
Merge pull request #682 from Instabug/refactor/android-dynamic-min-sdk-version
[MOB-8849] Get Android's `minSdkVersion` from user's Android project
2 parents d57ff22 + eef5ea5 commit 4258da9

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

android/build.gradle

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11

22
apply plugin: 'com.android.library'
33

4-
def DEFAULT_COMPILE_SDK_VERSION = 28
5-
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.0"
6-
def DEFAULT_TARGET_SDK_VERSION = 28
4+
String getExtOrDefault(String name) {
5+
if (rootProject.ext.has(name)) {
6+
return rootProject.ext.get(name)
7+
}
8+
return project.properties['InstabugReactNative_' + name]
9+
}
710

811
android {
9-
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
10-
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
12+
compileSdkVersion getExtOrDefault('compileSdkVersion').toInteger()
13+
buildToolsVersion getExtOrDefault('buildToolsVersion')
1114

1215
defaultConfig {
13-
minSdkVersion 16
14-
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
16+
minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
17+
targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
1518
versionCode 1
1619
versionName "1.0"
1720
ndk {

android/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
InstabugReactNative_compileSdkVersion=30
2+
InstabugReactNative_buildToolsVersion='30.0.2'
3+
InstabugReactNative_targetSdkVersion=31
4+
InstabugReactNative_minSdkVersion=16

0 commit comments

Comments
 (0)