Migrate to Version 6.4+
Please follow the below guide to migrate from the HyprMX SDK 6.x to 6.4+.
HyprMX SDK 6.4+ contains a revamp to our public API, streamlining our SDK's initialization and providing more focused callbacks and listeners. Additionally, we now provide modernized asynchronous APIs that you can opt into.
SDK migration
If you're using Gradle to manage your dependencies, you just need to bump the SDK dependency version number. Check out our SDK integration section for more info.
To migrate the HyprMX SDK, update the HyprMX SDK version number to 6.4.3 in your app's build.gradle file dependencies block:
dependencies {
implementation 'com.hyprmx.android:HyprMX-SDK:6.4.3'
}Fixing Your Broken Build
See below for migrations related to HyprMX SDK 6.4+.
Migrating HyprMX.initialize
The new SDK initializer parameters only require distributorId and vary slightly by result method. Following is a sample initializer for 6.4+ SDK:
HyprMX.INSTANCE.initialize(this, DISTRIBUTOR_ID, initializationListener);HyprMX.INSTANCE.initialize(this, DISTRIBUTOR_ID, result -> {
// do something
});HyprMX.initialize(this@MainActivity, DISTRIBUTOR_ID) { result ->
// do something
}val result = HyprMX.initialize(this@MainActivity, DISTRIBUTOR_ID)Other parameters have new setters. As a result, you will need to migrate the following parameters:
consentStatusageRestrictedUseruserID
Follow the steps below to migrate the parameters.
Migrating the consentStatus parameter
consentStatus parameterMigrating the ageRestrictedUser parameter
ageRestrictedUser parameterMigrating the userId parameter
userId parameterOur API no longer accepts user ID. Please remove it from the new method signature.
Migrating HyprMxIf.HyprMXInitializationListener
The initializationListener used by initialize, a few code snippets above, is an instance of HyprMxIf.HyprMXInitializationListener as it was in the HyprMX SDK 6.2, although its implementation changed.
The old initializationComplete and initializationFailed listeners were replaced with onInitialized. The latest will callback with a boolean flag to indicate whether the SDK was successfully initialized or not.
Migrating FullScreen Placement.loadAd
The new API doesn't require you to set a PlacementListener to load an ad. In fact, this listener no longer exists. Note: You can read more about it while migrating the Placement.showAd API.
To migrate existing code:
Remove the Placement.setPlacementListener(PlacementListener)
Replace the old Placement.loadAd and migrate the code you had inside PlacementListener.onAdAvailable and PlacementListener.onAdNotAvailable to the new loadAd callback.
Migrating FullScreen Placement.showAd
The new Placement.showAd API requires you to define a listener as an argument, HyprMXShowListener. This listener will provide a set of useful callbacks you might need to manipulate the UI state. In fact, some of the PlacementListener callbacks can now be migrated to the new HyprMXShowListener.
Here is a short comparison between PlacementListener and HyprMXShowListener:
To migrate existing code:
Remove the Placement.setPlacementListener(PlacementListener)
Replace the old Placement.showAd and set the HyprMXShowListener instance as argument
If you're working with rewarded placements, use HyprMXRewardedShowListener. This specialized listener includes an extra callback to handle the reward logic:
Note that onAdExpired also disappeared. If you need a callback to onAdExpired, then set HyprMXPlacementExpiryListener and call it on your placement using setPlacementExpiryListener.
Migrating Banner Placement.loadAd
The new API uses both async and synchronous methods to load a banner ad. To migrate existing code:
Remove the callback methods onAdLoaded and loadAdFailure.
Replace the old Placement.loadAd and migrate the code you had inside PlacementListener.onAdAvailable and PlacementListener.onAdNotAvailable to the new loadAd callback.
Migrating HyprMXBannerView
The new API uses both async and synchronous methods to load a banner ad. To migrate existing code:
Remove the callback methods onAdLoaded and onAdFailedToLoad from your HyprMXBannerListener listener implementation.
Replace the old hyprMXBannerView.loadAd() with either one of the following new methods:
That's it! You're done with the migration.
Last updated
