Upgrading to Android SDK v4

minSdkVersion changes

We have raised the required minSdkVersion to 21, released in 2014 and covers 95% of Android devices.

Make sure your application uses at least 21 in your app/build.gradle, otherwise you'll see the following build error:

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.wonderpush:wonderpush-android-sdk:4.0.1] [...]/.gradle/caches/transforms-2/files-2.1/110f18d74c064672b3bb9b02e46b3f51/jetified-wonderpush-android-sdk-4.0.1/AndroidManifest.xml as the library might be using APIs not available in 16
	Suggestion: use a compatible library with a minSdk of at most 16,
		or increase this project's minSdk version to at least 21,
		or use tools:overrideLibrary="com.wonderpush.sdk" to force usage (may lead to runtime failures)

Add the explicit dependency on our FCM compatibility module

In your app/build.gradle file, replace this:

// WonderPush SDK core module
implementation 'com.wonderpush:wonderpush-android-sdk:3.+'

with that:

// WonderPush SDK core module
implementation 'com.wonderpush:wonderpush-android-sdk:4.+'
// WonderPush compatibility module with Firebase Cloud Messaging
implementation 'com.wonderpush:wonderpush-android-sdk-fcm:1.+'


Troubleshooting the "no push service available" message

If you get the following error in your logs:

E/WonderPush.Push: Cannot refresh push subscription, no push service available

You need to add the following dependency in your app/build.gradle:

// WonderPush compatibility module with Firebase Cloud Messaging
implementation 'com.wonderpush:wonderpush-android-sdk-fcm:1.+'


Our SDK now depends on AndroidX to benefit from more modular dependencies.
If your application does not uses AndroidX yet, follow Android's Migrating to AndroidX guide.
Migrating is as easy as clicking on the Refactor > Migrate to AndroidX menu entry in Android Studio.

If your application does not use AndroidX you will see the following Gradle build errors:

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.collection:collection:1.0.0, androidx.cardview:cardview:1.0.0, androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.core:core:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.constraintlayout:constraintlayout:1.1.3, androidx.constraintlayout:constraintlayout-solver:1.1.3, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.annotation:annotation:1.0.0

Remove calls to deprecated APIs

Remove any calls to WonderPush.isReady() and local broadcast receivers registered on the INTENT_INITIALIZED intent.
You do not need to wait to use WonderPush.


You're done!