Configure the MobilePush SDK Flutter Plugin for Android Apps

After you install and configure the MobilePush SDK Flutter plugin, configure the plugin to enable push support for the Android platform.

The implementation steps can vary depending on your app and the Flutter version it uses.

To add the MobilePush SDK repository to your project, add this code to your android/build.gradle file.

To add the marketingcloudsdk dependency to your project, add this code to your android/app/build.gradle file.

In your app’s build.gradle file, set the SDK version parameters to the versions listed in this table.

ParameterVersion
compileSdk or compileSdkVersion35
minSdkVersion23

Ensure the org.jetbrains.kotlin.android or org.jetbrains.kotlin:kotlin-gradle-plugin plugin is version 1.9.10 or later.

Depending on your Flutter implementation, the location for specifying the Kotlin version can differ. You can specify the Kotlin version in either android/build.gradle or android/settings.gradle.

To enable push support for the Android platform, provide your Firebase Cloud Messaging (FCM) credentials by including the google-services.json file in your config.xml file.

  1. Download the google-services.json file from your application’s Firebase console and place it in your project’s android/app directory

  2. To include the Google Services plugin, add this code to your android/settings.gradle file.

    If pluginManagement isn’t present in your settings.gradle, add this dependency in android/build.gradle under the buildscript section. If the Gradle file doesn't have a buildscript section, add it.

  3. To apply the plugin, add this code to your android/app/build.gradle file.

    This step can vary depending on your implementation.

    If the plugins section doesn’t exist in your android/app/build.gradle file, add this code to the end of the file.

If MainApplication.kt isn’t present in your app, create it by extending the FlutterApplication class. Additionally, update AndroidManifest.xml.

Update MainApplication.kt in your app.

To customize push functionality, see Customize Push Notification Functionality for Android Apps.

To implement the Carousel and Button actions features introduced in Android SDK version 9.0.0, see Configure Button and Carousel Actions.

Update AndroidManifest.xml to declare the notification permission.

The SDK doesn’t automatically present URLs from these sources.

  • CloudPages URLs from push notifications
  • OpenDirect URLs from push notifications
  • Action URLs from in-app messages

To handle URLs from push notifications, follow these steps.

Navigate to MainApplication.kt and update setNotificationCustomizationOptions to include the code in this example.

  1. Open MainApplication.kt in an editor.

  2. In the setNotificationCustomizationOptions section, add these import statements.

  3. Update setNotificationCustomizationOptions in MarketingCloudConfig.

  4. Implement these methods in MainApplication.kt.

To handle URLs from in-app messages, set the setUrlHandler in MarketingCloudConfig as shown in this example.

Additionally, review the additional documentation on URL Handling for Android.

If you encounter errors related to Java sealed classes or dexing, add the r8 dependency to your app. For more information about this error, see Google’s IssueTracker.

To add the r8 dependency, update your app’s settings.gradle file.

If you don’t have pluginManagement in your settings.gradle file, update the buildscript.dependencies section of the android/build.gradle file.