Migrate to Adobe Experience Platform 2.x SDKs for Android
This Mobile SDK version for Android now supports a minimum API level of 19.
SDK versions
Android BOM
Android extensions
Extension | Version |
---|---|
Migrate from Adobe Experience Platform 1.x SDKs for Android
If you have implemented Adobe Experience Platform 1.x SDKs for Android, then this guide will help you understand the steps required to migrate your implementation to the Experience Platform 2.x SDKs. In summary, you'll need to:
Update dependencies
Gradle
The Adobe SDK BOM artifact enables managing all compatible versions of Adobe Experience Platform Android extensions by specifying a single BOM version. This is now the recommended way to manage Android SDKs. If you are using Gradle to manage your app dependencies, the following example shows how to start using BOM in the build.gradle
file.
Using dynamic dependency versions is not recommended for production apps. Refer to this page for managing Gradle dependencies.
Starting with version 2.0.0, the sdk-core
bundle (which includes Core, Lifecycle, Identity, Signal) will no longer receive updates. You need to include those libraries individually as described below.
Copied to your clipboarddependencies {//implementation 'com.adobe.marketing.mobile:sdk-core:1.+'//implementation 'com.adobe.marketing.mobile:userprofile:1.+'// Use Adobe SDK BOM artifact to manage all compatible versions of Adobe Experience Platform Android extensions.implementation platform('com.adobe.marketing.mobile:sdk-bom:2.+')implementation 'com.adobe.marketing.mobile:core'implementation 'com.adobe.marketing.mobile:identity'implementation 'com.adobe.marketing.mobile:signal'implementation 'com.adobe.marketing.mobile:lifecycle'implementation 'com.adobe.marketing.mobile:userprofile'}
Save the build.gradle
file and select Sync Project with Gradle Files
in Android Studio to download the 2.x SDKs.
Manual library import
If you are importing SDK libraries manually, make sure to update your libraries by downloading the most recent 2.x binaries directly from Maven Central Repository.
Update SDK initialization
After you have imported the new Android libraries, you'll need to update SDK initialization code as described below. With Mobile Core version 2.0.0 and above, the MobileCore.start()
API is no longer required. The SDK has simplified initialization and registration of extensions by providing the MobileCore.registerExtensions()
API. After the given extensions have been registered, the SDK will be initialized and the completion block will be executed. The code which used to reside in the start() block will now reside in the MobileCore.registerExtensions()
's completion block.
The following code snippets show the recommended initialization code for the 2.x Mobile SDKs.
Copied to your clipboardpublic class MainApp extends Application {private static final String ENVIRONMENT_FILE_ID = "<your_environment_file_id>";@Overridepublic void onCreate() {super.onCreate();MobileCore.setApplication(this);MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID);List<Class<? extends Extension>> extensions = new ArrayList<>();extensions.add(Lifecycle.EXTENSION);extensions.add(Signal.EXTENSION);extensions.add(UserProfile.EXTENSION);extensions.add(Assurance.EXTENSION);extensions.add(Identity.EXTENSION);MobileCore.registerExtensions(extensions, o -> {Log.d(LOG_TAG, "Adobe Experience Platform Mobile SDK is initialized");});}}
Copied to your clipboardclass MyApp : Application() {val ENVIRONMENT_FILE_ID = "<your_environment_file_id>"override fun onCreate() {super.onCreate()MobileCore.setApplication(this)MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID)val extensions = listOf(Identity.EXTENSION,Signal.EXTENSION,Lifecycle.EXTENSION,UserProfile.EXTENSION,Assurance.EXTENSION)MobileCore.registerExtensions(extensions) {Log.d(LOG_TAG, "Adobe Experience Platform Mobile SDK is initialized")}}}
Copied to your clipboardpublic class MainApp extends Application {private static final String ENVIRONMENT_FILE_ID = "<your_environment_file_id>";@Overridepublic void onCreate() {super.onCreate();MobileCore.setApplication(this);MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID);List<Class<? extends Extension>> extensions = new ArrayList<>();extensions.add(Lifecycle.EXTENSION);extensions.add(Signal.EXTENSION);extensions.add(UserProfile.EXTENSION);extensions.add(Assurance.EXTENSION);extensions.add(Identity.EXTENSION);MobileCore.registerExtensions(extensions, o -> {Log.d(LOG_TAG, "Adobe Experience Platform Mobile SDK is initialized");});}}
Copied to your clipboardclass MyApp : Application() {val ENVIRONMENT_FILE_ID = "<your_environment_file_id>"override fun onCreate() {super.onCreate()MobileCore.setApplication(this)MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID)val extensions = listOf(Identity.EXTENSION,Signal.EXTENSION,Lifecycle.EXTENSION,UserProfile.EXTENSION,Assurance.EXTENSION)MobileCore.registerExtensions(extensions) {Log.d(LOG_TAG, "Adobe Experience Platform Mobile SDK is initialized")}}}
Update outdated API references
Some of the APIs available in previous major versions of the Mobile SDK for Android are now deprecated or removed. You can choose to replace the obsolete APIs in your code with the alternative APIs in the 2.x version, as described below.
The registerExtension
API for each extension is deprecated in the 2.x version of the mobile SDK and will be removed in the 3.x version of the mobile SDK. You don't need to register extensions separately, now you can call MobileCore.registerExtensions
API instead. See the Update SDK initialization section for more details.
Profile
Deprecated API | Alternative API |
---|---|
UserProfile.updateUserAttribute | |
UserProfile.removeUserAttribute |
Adobe Target
Removed API | Alternative API |
---|---|
Target.locationsDisplayed | |
Target.locationClicked | |
com.adobe.marketing.mobile.TargetRequest | Moved into target subpackage. Update import statements to reference com.adobe.marketing.mobile.target.TargetRequest |
com.adobe.marketing.mobile.TargetPrefetch | Moved into target subpackage. Update import statements to reference com.adobe.marketing.mobile.target.TargetPrefetch |
com.adobe.marketing.mobile.TargetOrder | Moved into target subpackage. Update import statements to reference com.adobe.marketing.mobile.target.TargetOrder |
com.adobe.marketing.mobile.TargetProduct | Moved into target subpackage. Update import statements to reference com.adobe.marketing.mobile.target.TargetProduct |
com.adobe.marketing.mobile.TargetParameters | Moved into target subpackage. Update import statements to reference com.adobe.marketing.mobile.target.TargetParameters |
Adobe Campaign Classic
Removed API | Alternative API |
---|---|
CampaignClassic.registerDevice | The CampaignClassic.registerDevice API no longer provides a callback method for registration status since a false value cannot be accurately used as a signal to retry requests. |
Places Service
Removed API | Alternative API |
---|---|
Places.getNearbyPointsOfInterest API without the error callback | Use Places.getNearbyPointsOfInterest API which provides both successCallback and errorCallback |
com.adobe.marketing.mobile.PlacesAuthorizationStatus | Moved into places subpackage. Update import statements to reference com.adobe.marketing.mobile.places.PlacesAuthorizationStatus |
com.adobe.marketing.mobile.PlacesPOI | Moved into places subpackage. Update import statements to reference com.adobe.marketing.mobile.places.PlacesPOI |
com.adobe.marketing.mobile.PlacesRequestError | Moved into places subpackage. Update import statements to reference com.adobe.marketing.mobile.places.PlacesRequestError |
Network Override
The helper classes mentioned below for overriding the network service have been removed starting in the 2.x version of the mobile SDK. If you have implemented code to override network services, you will need to update it according to the guidance provided in this documentation.
Removed classes
AndroidNetworkServiceOverrider
AndroidNetworkServiceOverrider.HTTPConnectionPerformer
AndroidNetworkServiceOverrider.Connecting
Frequently asked questions
Is there a change in minimum API level supported by Mobile SDK for Android?
Mobile SDK for Android now supports a minimum API level of 19. If your application targets a lower API level, you will see the following build failure:
Copied to your clipboardManifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 19 declared in library [com.adobe.marketing.mobile:core:2.0.0]
To fix this build failure, increase the minSdkVersion for your Android project to 19 or above.
When I add Mobile SDK to my Android project, why do I get an error about invoke-custom support and enabling desugaring?
Mobile SDK for Android uses Java 8 language features and desugaring is disabled by default. If your application uses Android Gradle plugin (AGP) v4.2 and has not enabled Java 8 support, you will see the following build failure:
Copied to your clipboardD8: Invoke-customs are only supported starting with Android O (--min-api 26)Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradleandroid {compileOptions {sourceCompatibility 1.8targetCompatibility 1.8}}See https://developer.android.com/studio/write/java8-support.html for details.Alternatively, increase the minSdkVersion to 26 or above.
To fix this build failure, you can follow one of two options:
- Add the listed compileOptions from the error message to your app-level build.gradle file.
- Increase the minSdkVersion for your Android project to 26 or above.
Why do I see 'java.lang.NoSuchMethodError' after upgrading to the 2.x version of Mobile SDK for Android?
The Mobile Core 2.x SDK for Android includes changes that break compatiblity with solution SDKs developed for earlier verisons of the Mobile Core SDK.
If you attempt to use 2.x Mobile Core SDK and solution SDKs that were built for previous versions of Mobile Core to build your app, you may encounter the following error:
Copied to your clipboard2023-02-13 17:45:02.501 14264-14264/XXX E/AndroidRuntime: FATAL EXCEPTION: mainProcess: XXX, PID: XXXXXjava.lang.NoSuchMethodError: No static method getCore()Lcom/adobe/marketing/mobile/Core; in class Lcom/adobe/marketing/mobile/MobileCore; or its super classes (declaration of 'com.adobe.marketing.mobile.MobileCore' appears in XXX
To resolve this error, upgrade all your solution SDKs to the most recent versions.
Why do I not see 'sdk-core' dependency for 2.x version of Mobile SDK for Android?
The com.adobe.marketing.mobile:sdk-core dependency is no longer available for the 2.x version of Mobile SDK. Instead, select the appropriate solution SDKs based on your requirements from the following options:
Copied to your clipboardimplementation platform('com.adobe.marketing.mobile:sdk-bom:2.+')implementation 'com.adobe.marketing.mobile:core'implementation 'com.adobe.marketing.mobile:lifecycle'implementation 'com.adobe.marketing.mobile:identity'implementation 'com.adobe.marketing.mobile:signal'
How do I upgrade to the 2.x version of Mobile SDK for Android if my app uses Mobile Services?
Adobe Mobile Service's end-of-life date is December 31, 2022. To upgrade to the 2.x version of Mobile SDK for Android, you have to remove the Mobile Services dependency from your app.
Why do I see a warning in AndroidManifest.xml about missing 'com.adobe.marketing.mobile.FullscreenMessageActivity' class?
After upgrading to the 2.x version of Mobile SDK for Android, you will see the following build warning if your application previously set up in-app messages with Campaign Standard.
Copied to your clipboardClass referenced in the manifest, `com.adobe.marketing.mobile.FullscreenMessageActivity`, was not found in the project or the librariesUnresolved class 'FullscreenMessageActivity'
To resolve the build warning, remove FullscreenMessageActivity from your application's manifest file. Campaign Standard SDK no longer requires application to add FullscreenMessageActivity to their manifest.
Why do I see 'unresolved reference' error when upgrading Adobe Target SDK?
The 2.x version of Adobe Target Mobile SDK has the following breaking API changes for alignment with the iOS SDK:
- locationsDisplayed is now displayedLocations
- locationClicked is now clickedLocation
The public classes TargetRequest, TargetPrefetch, TargetOrder, TargetProduct and TargetParameters are consolidated under the target subpackage.
To resolve the error, fix the method references and update your target import statements:
Copied to your clipboardimport com.adobe.marketing.mobile.target.TargetRequest;import com.adobe.marketing.mobile.target.TargetPrefetch;import com.adobe.marketing.mobile.target.TargetOrder;import com.adobe.marketing.mobile.target.TargetProduct;import com.adobe.marketing.mobile.target.TargetParameters;
In addition, replace the previously deprecated Target APIs and classes since they have been removed. For more information, please read this section on the deprecated APIs and the recommended alternative APIs.
Why do I see registerDevice(String, String, Map<String, Object>)
cannot be applied to [arguments] error when upgrading Adobe Campaign Classic SDK?
The registerDevice
API in the 2.x Campaign Classic Android Mobile SDK, similar to iOS SDK, no longer provides a callback method for registration status since a false
value cannot be accurately used as a signal to retry requests.
To resolve the error, remove the callback (AdobeCallback<Boolean>
) parameter from the method invocation.
Why do I see getNearbyPointsOfInterest(Location, int, AdobeCallback<List<PlacesPOI>>, AdobeCallback<PlacesRequestError>)
cannot be applied to [arguments] error when upgrading Adobe Experience Platform Location Service SDK?
The getNearbyPointsOfInterest
API without the error callback has been removed. Alternatively, use the below overloaded API which provides both successCallback and errorCallback:
Copied to your clipboardpublic static void getNearbyPointsOfInterest(final Location location,final int limit,final AdobeCallback<List<PlacesPOI>> successCallback,final AdobeCallback<PlacesRequestError> errorCallback)
The public classes PlacesAuthorizationStatus
, PlacesPOI
, and PlacesRequestError
are consolidated under the places
subpackage.
To resolve the error, fix the method references and update your places import statements:
Copied to your clipboardimport com.adobe.marketing.mobile.places.PlacesAuthorizationStatus;import com.adobe.marketing.mobile.places.PlacesPOI;import com.adobe.marketing.mobile.places.PlacesRequestError;