Skip to content

Commit 5a01640

Browse files
committed
Fixes mix of android.support 26 and 28.
* If a project didn't use it's own copy of android.support or AndroidX it would result in duplicated android.support classes - Due to a mixture of android.support from fcm & gms depending on 26 and OneSignal using 28. * Removed version alignment from maven-push.gradle and move version ranges into onesignal/build.gradle. - As of Firebase & gms 16 versions aren't expected to line up any more. * Added a number of comments to why specific version ranges are used.
1 parent 95b5211 commit 5a01640

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

OneSignalSDK/onesignal/build.gradle

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,39 @@ android {
3030

3131
// api || implementation = compile and runtime
3232

33+
// KEEP: version ranges, these get used in the released POM file for maven central
3334
dependencies {
3435
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
3536

36-
compileOnly 'com.google.android.gms:play-services-gcm:16.0.0'
37+
// play-services-gcm:16.1.0 is the last version before going to AndroidX
38+
// compileOnly as this is just for fallback code if FCM wasn't added to the project.
39+
// Remove for 4.0.0 release
40+
compileOnly 'com.google.android.gms:play-services-gcm:16.1.0'
41+
42+
// play-services-location:16.0.0 is the last version before going to AndroidX
3743
// Can be compileOnly in 4.0.0, can't change until then as some projects may rely on this
38-
implementation 'com.google.android.gms:play-services-location:16.0.0'
39-
implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
40-
// Required for GoogleApiAvailability
41-
implementation 'com.google.android.gms:play-services-base:16.0.1'
44+
implementation 'com.google.android.gms:play-services-location:[10.2.1, 16.0.99]'
4245

43-
api 'com.google.firebase:firebase-messaging:17.3.3'
46+
// play-services-ads-identifier:15.0.0 first version
47+
// Classes used to live in play-services-base before this
48+
// play-services-ads-identifier:16.0.0 is the last version before going to AndroidX
49+
implementation 'com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]'
50+
51+
// :play-services-base:16.1.0 is the last version before going to AndroidX
52+
// Required for GoogleApiAvailability
53+
implementation 'com.google.android.gms:play-services-base:[10.2.1, 16.1.99]'
4454

45-
api 'com.android.support:cardview-v7:28.0.0'
46-
api 'com.android.support:support-v4:28.0.0'
47-
api 'com.android.support:customtabs:28.0.0'
55+
// firebase-messaging:18.0.0 is the last version before going to AndroidX
56+
// firebase-messaging:17.6.0 is the max version since we still have code looking for FirebaseInstanceIdService
57+
api 'com.google.firebase:firebase-messaging:[10.2.1, 17.3.99]'
4858

49-
// Change api to implementation. Need to check however this has any effect in production
50-
// projects that pull from maven.
59+
// Keep under 28 until we switch to AndroidX
60+
// otherwise app can get dup classes between 26 & 28 when mixing these versions.
61+
// Also note, firebase & gms libraries use android.support:26.
62+
// - They never refer to 27 or 28
63+
api 'com.android.support:cardview-v7:[26.0.0, 27.99.99]'
64+
api 'com.android.support:support-v4:[26.0.0, 27.99.99]'
65+
api 'com.android.support:customtabs:[26.0.0, 27.99.99]'
5166
}
5267

5368
apply from: 'maven-push.gradle'

OneSignalSDK/onesignal/maven-push.gradle

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ class Global {
2626
static def POM_PACKAGING = 'aar'
2727
static def VERSION_NAME = '3.12.1'
2828

29-
// Limit upper number (exclusive) to prevent untested versions
30-
static def versionGroupOverrides = [
31-
'com.google.android.gms': '[10.2.1, 16.1.0)',
32-
'com.google.firebase': '[10.2.1, 16.1.0)',
33-
'com.android.support': '[26.0.0, 28.1.0)'
34-
]
35-
3629
static def GROUP_ID = 'com.onesignal'
3730
static def POM_DESCRIPTION = 'OneSignal Android SDK'
3831
static def POM_URL = 'https://github.com/one-signal/OneSignal-Android-SDK'
@@ -70,17 +63,6 @@ afterEvaluate { project ->
7063
pom.artifactId = Global.POM_ARTIFACT_ID
7164
pom.version = Global.VERSION_NAME
7265

73-
pom.withXml {
74-
asNode().dependencies.'*'.findAll() {
75-
def versionOverride = Global.versionGroupOverrides[it.groupId.text()]
76-
if (versionOverride) {
77-
it.version.replaceNode { node ->
78-
new Node(it, "version", versionOverride)
79-
}
80-
}
81-
}
82-
}
83-
8466
repository(url: Global.RELEASE_REPOSITORY_URL) {
8567
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
8668
}

OneSignalSDK/onesignal/src/main/java/com/onesignal/PushRegistratorFCM.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class PushRegistratorFCM extends PushRegistratorAbstractGoogle {
5252
// needs to be refreshed.
5353
// This checks for gcm_defaultSenderId in values.xml (normally added from google-services.json)
5454
// https://github.com/OneSignal/OneSignal-Android-SDK/issues/552
55+
// TODO: FirebaseInstanceIdService was removed in firebase-messaging:18.0.0
56+
// Can remove this method once this is our minimum version
5557
static void disableFirebaseInstanceIdService(Context context) {
5658
String senderId = OSUtils.getResourceString(context, "gcm_defaultSenderId", null);
5759
int componentState =

0 commit comments

Comments
 (0)