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
| v4 | v5 | |
|---|---|---|
| Initialization | automatic, at app start (BootstrapContextProvider) | explicit — AdGem.get().initialize(Context, AdGemConfig) in Application.onCreate() |
| App ID | res/xml/adgem_config.xml + com.adgem.Config manifest meta-data | new AdGemConfig.Builder("ADGEM_APP_ID") |
| Set the player | adGem.setPlayerMetaData(player) | AdGem.get().setPlayer(player) |
| Player ID | PlayerMetadata.Builder.createWithPlayerId(id) | required in the constructor — new PlayerMetadata.Builder(id) |
| Player ID limit | 65535 characters | 256 characters (as documented) |
createdAt(...) | preformatted String | java.util.Date, serialized as yyyy-MM-dd HH:mm:ss in UTC |
| Load failures | onOfferwallLoadingFailed(String) | onOfferwallLoadingFailed(AdGemError) with Kind (NOT_INITIALIZED, NOT_READY, OFFERWALL_UNAVAILABLE, INTERNAL) |
| Session pings | on every app foreground | only on setPlayer() |
| HTTP inspection | setHttpInterceptor(...) | removed — use Charles, mitmproxy, or Android Studio's Network Inspector |
| Teardown | — | AdGem.get().close() |
Migrate
- Initialize explicitly. Delete
res/xml/adgem_config.xmland thecom.adgem.Config<meta-data>tag fromAndroidManifest.xml, then callAdGem.get().initialize(this, new AdGemConfig.Builder("ADGEM_APP_ID").build())in yourApplication.onCreate(). Auto-init is gone — nothing happens until you callinitialize(). - Update the player setup. Replace
PlayerMetadata.Builder.createWithPlayerId("id")withnew PlayerMetadata.Builder("id"), andadGem.setPlayerMetaData(player)withAdGem.get().setPlayer(player). - Pass
createdAtas aDate.createdAt(...)now takes ajava.util.Dateinstead of a preformatted string; the SDK serializes it asyyyy-MM-dd HH:mm:ssin UTC. - 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. - Handle typed errors. Change
onOfferwallLoadingFailed(String)toonOfferwallLoadingFailed(AdGemError)and branch onerror.getKind();INTERNALerrors carry the underlying throwable viaerror.getCause(). - Remove
setHttpInterceptor(...)usages. For HTTP-level traffic inspection use Charles, mitmproxy, or Android Studio's Network Inspector. - Adopt
close()where useful. CallAdGem.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.