Skip to content

Commit d448d87

Browse files
committed
feat: backwards-compatible AndroidX support Fixes #674, #724, #726
1 parent 5ded12c commit d448d87

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

android/build.gradle

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.3.2'
8+
classpath 'com.android.tools.build:gradle:3.4.2'
99
}
1010
}
1111

@@ -40,10 +40,18 @@ repositories {
4040
}
4141

4242
dependencies {
43+
// Use either AndroidX library names or old/support library names based on major version of support lib
44+
def supportLibVersion = safeExtGet('supportLibVersion', '28.0.0')
45+
def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
46+
def appCompatLibName = (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"
47+
def supportV4LibName = (supportLibMajorVersion < 20) ? "androidx.legacy:legacy-support-v4" : "com.android.support:support-v4"
48+
def supportV4Version = safeExtGet('supportV4Version', safeExtGet('supportLibVersion', '28.0.0'))
49+
def mediaCompatLibName = (supportLibMajorVersion < 20) ? "androidx.media:media" : "com.android.support:support-media-compat"
50+
def mediaCompatVersion = safeExtGet('mediaCompatVersion', safeExtGet('supportLibVersion', '28.0.0'))
51+
4352
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
4453
implementation "com.google.android.gms:play-services-gcm:${safeExtGet('googlePlayServicesVersion', '16.1.0')}"
45-
//noinspection GradleCompatible
46-
implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
47-
implementation "com.android.support:support-v4:${safeExtGet('supportLibVersion', '28.0.0')}"
48-
implementation "com.android.support:support-media-compat:${safeExtGet('supportLibVersion', '28.0.0')}"
54+
implementation "$appCompatLibName:$supportLibVersion"
55+
implementation "$supportV4LibName:$supportV4Version"
56+
implementation "$mediaCompatLibName:$mediaCompatVersion"
4957
}

0 commit comments

Comments
 (0)