Nimbus Android SDK

Quickstart Guide

Using the Nimbus Android SDK, you can monetize your app with embedded video and static ads. Nimbus brings the "header bidding" process to in-app mobile. Nimbus holds a simultaneous auction for over a dozen major ad networks at the beginning of every user session, delivering the highest-paid ad to the user.

Build Setup

Include the following maven repository configuration in your project root build.gradle file. Your credentials for the additional repositories can be found on the Nimbus Dashboard. Contact your account manager for access to the Nimbus Dashboard.

Nimbus Dashboard Android SDK Setup

Gradle > 6.8 (settings.gradle.kts)
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        // Add the following maven repository for access to the Nimbus SDK
        maven {
            url = uri("https://adsbynimbus-public.s3.amazonaws.com/android/sdks")
            credentials {
                username = "*"
            }
            content {
                includeGroupByRegex(".*\.adsbynimbus.*")
            }
        }
    }
}
Other Gradle Versions (build.gradle.kts)
allprojects {
    repositories {
        google()
        mavenCentral()
        // Add the following maven repository for access to the Nimbus SDK
        maven {
            url = uri("https://adsbynimbus-public.s3.amazonaws.com/android/sdks")
            credentials {
                username = "*"
            }
            content {
                includeGroup("com.adsbynimbus.openrtb")
                includeGroup("com.adsbynimbus.android")

                // Include the following if implementing OM Viewability measurement
                includeGroup("com.iab.omid.library.adsbynimbus")
            }
        }
    }
}

In your application's build.gradle file, include the Nimbus sdk and required OkHttp extension and ensure compilation is set to target Java 8.

// app/build.gradle
apply plugin: 'com.android.application'

android {

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    // If using Kotlin
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation "com.adsbynimbus.android:nimbus:2.1.0" // Full Nimbus SDK with NimbusAdManager
}

Initialize Nimbus SDK

lateinit var context: Context
lateinit var publisherKey: String
lateinit var apiKey: String
Nimbus.initialize(context, publisherKey, apiKey)

Set test mode

Nimbus.testMode = true

If initializing with a dev key, test mode is required to see test ads. Test mode must be turned off before release to production.

Show an Ad

val manager = NimbusAdManager()

// Obtain the ViewGroup from your layout to attach the ad
var adView: ViewGroup = findViewById(R.id.ad_view)

// Call showAd for non-blocking ads, an ad will attach to 'adView' on a successful request and return in the callback
manager.showBlockingAd(NimbusRequest.forInterstitialAd("position"), activity, object : NimbusAdManager.Listener {

    override fun onAdResponse(nimbusResponse: NimbusResponse) {
        TODO("Optional override to receive a callback when a successful bid is made")
    }

    override fun onAdRendered(controller: AdController) {
        TODO("Ad successfully loaded, attach an event listener to listen to ad events")
    }

    override fun onError(error: NimbusError) {
        TODO("Handle error")
    }
})

// Call showBlocking ad to show a blocking fullscreen ad
manager.showBlockingAd(NimbusRequest.forInterstitialAd("position"), activity, object : NimbusAdManager.Listener {

    override fun onAdResponse(nimbusResponse: NimbusResponse) {
        TODO("Optional override to receive a callback when a successful bid is made")
    }

    override fun onAdRendered(controller: AdController) {
        TODO("Ad successfully loaded, attach an event listener to listen to ad events")
        TODO("Call controller.stop() to hide the ad and controller.destroy() to remove it completely")
    }

    override fun onError(error: NimbusError) {
        TODO("Handle error")
    }
})

Proguard/R8

If you are using R8, all the necessary proguard rules are included for you and should work out of the box.

If you are using Proguard or if you run into any build issues, see Proguard/R8 in Debugging to troubleshoot.

Explore the SDK

For more advanced topics continue reading using the links in the sidebar

Get support

Contact your Nimbus agent to get help with the SDK.