Skip to main content

Android SDK v4 → v5

Android SDK 5.0.0 makes the SDK lifecycle explicit: the host app initializes the SDK in code, sets the player, and can tear the SDK down. Configuration via res/xml/adgem_config.xml and auto-initialization are removed, and errors become typed. See the Android SDK integration guide for the full walkthrough.

Side by side

v4v5
Initializationautomatic, at app start (BootstrapContextProvider)explicit — AdGem.get().initialize(Context, AdGemConfig) in Application.onCreate()
App IDres/xml/adgem_config.xml + com.adgem.Config manifest meta-datanew AdGemConfig.Builder("ADGEM_APP_ID")
Set the playeradGem.setPlayerMetaData(player)AdGem.get().setPlayer(player)
Player IDPlayerMetadata.Builder.createWithPlayerId(id)required in the constructor — new PlayerMetadata.Builder(id)
Player ID limit65535 characters256 characters (as documented)
createdAt(...)preformatted Stringjava.util.Date, serialized as yyyy-MM-dd HH:mm:ss in UTC
Load failuresonOfferwallLoadingFailed(String)onOfferwallLoadingFailed(AdGemError) with Kind (NOT_INITIALIZED, NOT_READY, OFFERWALL_UNAVAILABLE, INTERNAL)
Session pingson every app foregroundonly on setPlayer()
HTTP inspectionsetHttpInterceptor(...)removed — use Charles, mitmproxy, or Android Studio's Network Inspector
TeardownAdGem.get().close()

Migrate

  1. Initialize explicitly. Delete res/xml/adgem_config.xml and the com.adgem.Config <meta-data> tag from AndroidManifest.xml, then call AdGem.get().initialize(this, new AdGemConfig.Builder("ADGEM_APP_ID").build()) in your Application.onCreate(). Auto-init is gone — nothing happens until you call initialize().
  2. Update the player setup. Replace PlayerMetadata.Builder.createWithPlayerId("id") with new PlayerMetadata.Builder("id"), and adGem.setPlayerMetaData(player) with AdGem.get().setPlayer(player).
  3. Pass createdAt as a Date. createdAt(...) now takes a java.util.Date instead of a preformatted string; the SDK serializes it as yyyy-MM-dd HH:mm:ss in UTC.
  4. Check your player IDs. IDs longer than 256 characters are now rejected. If you don't know a player's gender, pass PlayerMetadata.Gender.UNKNOWN (new) to omit the parameter.
  5. Handle typed errors. Change onOfferwallLoadingFailed(String) to onOfferwallLoadingFailed(AdGemError) and branch on error.getKind(); INTERNAL errors carry the underlying throwable via error.getCause().
  6. Remove setHttpInterceptor(...) usages. For HTTP-level traffic inspection use Charles, mitmproxy, or Android Studio's Network Inspector.
  7. Adopt close() where useful. Call AdGem.get().close() on user logout, A/B variant changes, or in tests; re-initialize afterwards to use the SDK again (player metadata must be set again).

Behavioral note: /session pings no longer fire on every app foreground — only on setPlayer() — matching the iOS SDK. No action is needed unless you relied on the per-foreground pings.