Android integration

Getting started

ApexAd is split into a dependency-light core and optional format or capability modules. Add the smallest surface you need, initialize once, then let each ad object own its load, show and destroy lifecycle.

Maven Central publication is being activated

The `net.apexsdk` coordinates shown here are the signed release coordinates. They become downloadable after domain verification and the first Central deployment. Until then, use the source checkout and demo application.

Requirements

Minimum AndroidAPI 21 for core and standard format modules
Integrity moduleAPI 23 or later
Compile SDK35 in the current source release
Java bytecodeJava 17 toolchain
LicenseApache License 2.0

Install

Add Maven Central to dependency resolution, then select core plus the format modules used by the application.

settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}
app/build.gradle.kts
dependencies {
    implementation("net.apexsdk:apex-sdk-core:0.1.0")
    implementation("net.apexsdk:apex-sdk-banner:0.1.0")
    implementation("net.apexsdk:apex-sdk-interstitial:0.1.0")
    implementation("net.apexsdk:apex-sdk-native:0.1.0")
}

Keep all Apex modules on the same version. Optional modules declare their required Apex module dependencies through Maven metadata.

Module map

ArtifactPurposeNotes
apex-sdk-coreInitialization, OpenRTB, consent, tracking, cache and runtime contractsRequired
apex-sdk-bannerBanner, MRECT and MRAID renderingOptional
apex-sdk-interstitialFullscreen display lifecycleOptional
apex-sdk-nativeIAB Native 1.2 parsing and view bindingOptional
apex-sdk-conversationalSponsored suggestions for in-app assistant surfacesDepends on Native
apex-sdk-videoVAST video parsing, playback and reward callbacksOptional
apex-sdk-appopenForeground lifecycle ads and frequency capsOptional
apex-sdk-inappbiddingBid token and price signal for mediationOptional
apex-sdk-walletGoogle Wallet action capabilityOptional Google dependency
apex-sdk-integrityPlay Integrity leases and request signingAPI 23+
apex-sdk-measurementOM SDK integration boundaryPartner activation required
apex-adapter-admobAdMob mediation adapterOptional

Initialize once

Initialize from Application.onCreate(). The application token identifies the registered publisher application. The endpoint override is useful for private OpenRTB integrations; production applications should use HTTPS.

Application.kt
class PublisherApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val tcfString = getSharedPreferences("IABTCF", MODE_PRIVATE)
            .getString("IABTCF_TCString", null)

        val config = ApexAdsConfig.Builder("YOUR_APP_TOKEN")
            .adServerUrl("https://your-openrtb-endpoint.example/auction")
            .cacheTtlSeconds(300)
            .gdprConsentString(tcfString)
            .build()

        ApexAds.init(this, config)
    }
}
Do not put server secrets in the Android application

The publisher token identifies a registered app. Demand API keys, signing lease secrets, service-account credentials and private PGP keys stay server-side.

Load a first banner

Add the view to a publisher layout, then create the ad with a placement identifier configured on the server.

layout.xml
PublisherActivity.kt

Lifecycle contract

Ad objects move through deterministic states: idle, loading, loaded, displayed, expired or failed. Preload fullscreen formats before the transition where they may be shown. Destroy an ad or its rendering view when the owning Android lifecycle is permanently finished.

Host eventPublisher action
Screen becomes eligibleCreate the ad and call load().
Listener reports loadedRender banner/native immediately or hold fullscreen format until the intended transition.
Natural pause occursCheck readiness, then call show(activity).
Screen is permanently destroyedCall the format's destroy or view cleanup method.
Load fails or no-fillsPreserve the app experience; never block content waiting for an ad.

Next steps

Continue with the format-specific examples, then review privacy and production activation requirements before connecting real inventory.

Explore ad formats Review trust and privacy