Skip to content

Commit df0e12e

Browse files
RMET-2824 OneSignal-Android-SDK - Remove android support library and migrate to AndroidX (#20)
* feat: replace android's Support Library with AndroidX Context: MABS 10 builds won't work if there are dependencies to the Support Library, so we must migrate. References: https://outsystemsrd.atlassian.net/browse/RMET-2824 * misc: raise version and comment lines to generate new .aar * fix: enableJetifier Context: So that the Android plugin automatically migrate existing third-party libraries to use AndroidX dependencies. More info: https://developer.android.com/jetpack/androidx#using_androidx_libraries_in_your_project References: https://outsystemsrd.atlassian.net/browse/RMET-2824 * misc: raise version to test * chore: raise version to 3.15.5.-OS4 References: https://outsystemsrd.atlassian.net/browse/RMET-2824 * refactor: remove extra line References: https://outsystemsrd.atlassian.net/browse/RMET-2824 * misc: uncomment previously commented lines * refactor: fix spacing References: https://outsystemsrd.atlassian.net/browse/RMET-2824 * refactor: remove extra lines References: https://outsystemsrd.atlassian.net/browse/RMET-2824
1 parent 60ba816 commit df0e12e

123 files changed

Lines changed: 234 additions & 271 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

OneSignalSDK/app/build.gradle

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ apply plugin: 'com.android.application'
88
//apply plugin: com.onesignal.androidsdk.GradleProjectPlugin
99

1010
android {
11-
compileSdkVersion 28
11+
compileSdkVersion 31
1212
buildToolsVersion '28.0.3'
1313
defaultConfig {
1414
applicationId "com.onesignal.example"
1515
manifestPlaceholders = [onesignal_app_id: "b2f7f966-d8cc-11e4-bed1-df8f05be55ba",
1616
// Project number pulled from dashboard, local value is ignored.
1717
onesignal_google_project_number: "REMOTE"]
18-
minSdkVersion 17
19-
targetSdkVersion 28
18+
minSdkVersion 26
19+
targetSdkVersion 31
2020
versionCode 1
2121
versionName "1.0"
2222
}
2323

2424
lintOptions {
2525
abortOnError false
26+
checkReleaseBuilds false
2627
}
2728

2829
buildTypes {
@@ -39,12 +40,11 @@ android {
3940
}
4041

4142
repositories {
42-
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
43+
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
4344
}
4445

4546
dependencies {
4647
implementation fileTree(include: ['*.jar'], dir: 'libs')
47-
implementation 'com.android.support:appcompat-v7:28.0.0'
4848

4949
// Use for SDK Development
5050
implementation(project(':onesignal')) {
@@ -56,6 +56,8 @@ dependencies {
5656
// exclude group: 'com.google.firebase', module: 'firebase-messaging'
5757
}
5858

59+
implementation 'androidx.annotation:annotation-jvm:1.7.0'
60+
5961
// Use snapshot
6062
// compile 'com.onesignal:OneSignal:4.0.0-SNAPSHOT'
6163
// compile 'com.onesignal:OneSignal:4.0.0-20171206.043726-5'
@@ -69,10 +71,4 @@ dependencies {
6971
// Old Instructions - Use for released SDK
7072
// compile 'com.onesignal:OneSignal:3.+@aar'
7173

72-
implementation 'com.google.android.gms:play-services-location:16.0.0'
73-
74-
// For Chrome tabs
75-
implementation 'com.android.support:customtabs:28.0.0'
7674
}
77-
78-
//apply plugin: 'com.google.gms.google-services'

OneSignalSDK/app/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,3 @@
8484
public static <fields>;
8585
}
8686

87-
# The support library contains references to newer platform versions.
88-
# Don't warn about those in case this app is linking against an older
89-
# platform version. We know about them, and they are safe.
90-
-dontwarn android.support.**
91-
92-
# Understand the @Keep support annotation.
93-
-keep class android.support.annotation.Keep
94-
95-
-keep @android.support.annotation.Keep class * {*;}
96-
97-
-keepclasseswithmembers class * {
98-
@android.support.annotation.Keep <methods>;
99-
}
100-
101-
-keepclasseswithmembers class * {
102-
@android.support.annotation.Keep <fields>;
103-
}
104-
105-
-keepclasseswithmembers class * {
106-
@android.support.annotation.Keep <init>(...);
107-
}

OneSignalSDK/app/src/main/java/com/onesignal/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import android.os.Bundle;
3535
import android.os.Handler;
3636
import android.os.Looper;
37-
import android.support.annotation.Nullable;
37+
import androidx.annotation.Nullable;
3838
import android.util.Log;
3939
import android.view.Menu;
4040
import android.view.MenuItem;

OneSignalSDK/app/src/main/java/com/onesignal/example/NotificationExtenderServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.onesignal.example;
22

3-
import android.support.v4.app.NotificationCompat;
3+
import androidx.core.app.NotificationCompat;
44

55
import com.onesignal.OSNotificationPayload;
66
import com.onesignal.NotificationExtenderService;

OneSignalSDK/app/src/main/java/com/onesignal/example/OneSignalExampleApp.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
import android.content.Context;
3232
import android.content.SharedPreferences;
3333
import android.os.StrictMode;
34-
import android.support.annotation.NonNull;
35-
import android.support.annotation.Nullable;
3634
import android.util.Log;
3735

36+
import androidx.annotation.NonNull;
37+
import androidx.annotation.Nullable;
38+
3839
import com.onesignal.OSNotification;
3940
import com.onesignal.OSNotificationOpenResult;
4041
import com.onesignal.OneSignal;

OneSignalSDK/build.gradle

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,9 @@ buildscript {
1414
maven { url 'http://developer.huawei.com/repo/' }
1515
}
1616
dependencies {
17-
classpath 'com.android.tools.build:gradle:3.5.0'
18-
19-
classpath 'com.google.gms:google-services:4.3.2'
17+
classpath 'com.android.tools.build:gradle:3.6.2'
18+
classpath 'com.google.gms:google-services:4.3.3'
2019
classpath 'com.huawei.agconnect:agcp:1.2.1.301'
21-
22-
// com.huawei.agconnect Gradle Plugin
23-
24-
// OneSignal-Gradle-Plugin - Local testing
25-
// classpath 'com.onesignal:onesignal-gradle-plugin:[0.8.1, 0.99.99]'
26-
27-
// OneSignal-Gradle-Plugin - Public version
28-
// classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.8.1, 0.99.99]'
2920
}
3021
}
3122

OneSignalSDK/gradle.properties

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ android.databinding.incremental = false
2727
kapt.incremental.apt = false
2828
android.testConfig.useRelativePath = false
2929

30-
# Disables R8 for Android Library modules only
31-
android.enableR8.libraries = false
32-
# Disables R8 for all modules.
33-
android.enableR8 = true
30+
# Enables D8 for all modules.
3431
android.enableD8 = true
3532

3633
# Android X settings
37-
android.enableJetifier = false
38-
android.useAndroidX = false
34+
android.enableJetifier = true
35+
android.useAndroidX = true

OneSignalSDK/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

OneSignalSDK/onesignal/build.gradle

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 28
4+
compileSdkVersion 31
55
defaultConfig {
66
// Normally we shouldn't need to redefine manifestPlaceholders for our onesignal project
77
// but Android Studio gets a sync error if these are not here.
@@ -10,7 +10,8 @@ android {
1010
manifestPlaceholders = [onesignal_app_id: '${onesignal_app_id}',
1111
// Project number pulled from dashboard, local value is ignored
1212
onesignal_google_project_number: '${onesignal_google_project_number}']
13-
minSdkVersion 15
13+
minSdkVersion 26
14+
targetSdkVersion 31
1415
consumerProguardFiles 'consumer-proguard-rules.pro'
1516
}
1617

@@ -44,37 +45,37 @@ dependencies {
4445
compileOnly 'com.google.android.gms:play-services-gcm:16.1.0'
4546

4647
// play-services-location:16.0.0 is the last version before going to AndroidX
47-
// Can be compileOnly in 4.0.0, can't change until then as some projects may rely on this
48-
implementation 'com.google.android.gms:play-services-location:[10.2.1, 16.0.99]'
48+
// play-services-location:17.0.0 is the first version using AndroidX
49+
compileOnly 'com.google.android.gms:play-services-location:[17.0.0, 17.99.99]'
4950

50-
// play-services-ads-identifier:15.0.0 first version
51-
// Classes used to live in play-services-base before this
5251
// play-services-ads-identifier:16.0.0 is the last version before going to AndroidX
53-
implementation 'com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99]'
52+
// play-services-ads-identifier:17.0.0 is the first version using AndroidX
53+
// Classes used to live in play-services-base before this
54+
implementation 'com.google.android.gms:play-services-ads-identifier:[17.0.0, 17.99.99]'
5455

55-
// :play-services-base:16.1.0 is the last version before going to AndroidX
56+
// play-services-base:16.1.0 is the last version before going to AndroidX
57+
// play-services-base:17.0.0 is the first version using AndroidX
5658
// Required for GoogleApiAvailability
57-
implementation 'com.google.android.gms:play-services-base:[10.2.1, 16.1.99]'
59+
implementation 'com.google.android.gms:play-services-base:[17.0.0, 17.99.99]'
5860

5961
// firebase-messaging:18.0.0 is the last version before going to AndroidX
6062
// firebase-messaging:17.6.0 is the max version since we still have code looking for FirebaseInstanceIdService
61-
api 'com.google.firebase:firebase-messaging:[10.2.1, 17.3.99]'
63+
api 'com.google.firebase:firebase-messaging:17.6.0'
6264

6365
// Huawei PushKit
6466
// KEEP as "compileOnly", so OneSignal isn't a direct dependency in the POM file.
6567
compileOnly 'com.huawei.hms:push:4.0.3.301'
6668
compileOnly 'com.huawei.hms:location:4.0.0.300'
6769

68-
// Keep under 28 until we switch to AndroidX
69-
// otherwise app can get dup classes between 26 & 28 when mixing these versions.
70-
// Also note, firebase & gms libraries use android.support:26.
71-
// - They never refer to 27 or 28
72-
api 'com.android.support:cardview-v7:[26.0.0, 27.99.99]'
73-
api 'com.android.support:support-fragment:[26.0.0, 27.99.99]'
74-
api 'com.android.support:customtabs:[26.0.0, 27.99.99]'
70+
api 'androidx.cardview:cardview:[1.0.0, 1.99.99]'
71+
api 'androidx.legacy:legacy-support-v4:[1.0.0, 1.99.99]'
72+
api 'androidx.browser:browser:[1.0.0, 1.99.99]'
73+
api 'androidx.appcompat:appcompat:[1.0.0, 1.99.99]'
7574

76-
// compileOnly as this is just for fallback code if AppCompatActivity wasn't added to the project.
77-
compileOnly 'com.android.support:appcompat-v7:26.1.0'
75+
implementation 'androidx.annotation:annotation-jvm:1.7.0'
76+
77+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"
78+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
7879
}
7980

8081
apply from: 'maven-push.gradle'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import android.os.Handler;
3636
import android.os.HandlerThread;
3737
import android.os.Looper;
38-
import android.support.annotation.NonNull;
38+
import androidx.annotation.NonNull;
3939
import android.view.ViewTreeObserver;
4040

4141
import java.lang.ref.WeakReference;

0 commit comments

Comments
 (0)