Important: As an App developer, as the controller of data, you must ensure that you have received unambiguous and informed consent from a user before sharing any of their data with Leadbolt or before calling any Leadbolt SDK functions for that user. Please ensure your app is updated as required.

This page will show you how to integrate Leadbolt Video and Interstitial ads in your Android app. Download the SDK and sample app. Make sure you can compile the sample app and see test ads.


Before you begin Before you begin

  • Have you logged in to the Leadbolt Publisher Portal?
  • Did you add an App in the portal?
  • Ensure, you have downloaded the Leadbolt SDK and sample app from the link above
  • Add the required permission android.permission.INTERNET in your AndroidManifest.xml file
  • Add the required permission android.permission.ACCESS_NETWORK_STATE in your AndroidManifest.xml file
  • To ensure your App is compatible with Android 6.0 and above devices, set the project’s Build and Compile SDK Version to API Level 25 or above in your build.gradle file

    compileSdkVersion = 25
    buildToolsVersion = '25.0.3'
  • Also set the Target SDK Version in your App’s AndroidManifest.xml file to 23 or higher to target Android 6.0 features


Step 1 Add Leadbolt SDK Jar file

  • Copy the downloaded AppTracker.jar file to your Android Project’s “libs” folder. If folder doesn’t exist, create one and add the jar file to it

Step 2 Add Google Play Services

  • The Google Play services are needed to be added in your App to enable the Leadbolt SDK to use the Google Advertising ID.
  • Follow the setup instructions from Google to include the library in your App. If you are using Google Play services v12.0.0 or higher, you will need to set the dependencies as play-services-base and play-services-ads-identifier, while older Google Play Services version need the dependency play-services-ads

Step 3 Add Leadbolt Activity to AndroidManifest.xml file

  • Add the required Leadbolt Activity in your AndroidManifest.xml

Step 4 Add Leadbolt SDK Imports

  • Add the following Leadbolt SDK import statements to all your App’s Activities that will use the Leadbolt SDK.

Step 5 Initialize Leadbolt SDK

  • In your App’s launcher Activity, add the following code to your Activity’s onCreate method.

    You will need to replace "YOUR_APP_API_KEY"  with the specific api key for your app (include the double quotes).

Step 6 To Cache and Show a non-Rewarded Ad

  • To cache a non-Rewarded Ad

  • To show a non-Rewarded Ad

  • Please ensure that in your code, you do not call loadModule directly after loadModuleToCache. It will cause the SDK to fail and not display an Ad all together.
  • For Advanced SDK options, including use of Event Listeners, click here.

Step 7 To Cache and Show a Rewarded Ad

  • To cache a Rewarded Ad

  • To show a Rewarded Ad

  • Please ensure that in your code, you do not call loadModule directly after loadModuleToCache. It will cause SDK to fail and not display the Rewarded Ad at all.
  • To reward user, refer to the Advanced Integration on more information about Event Listeners and Rewarding Users

Step 8 Obfuscating your App with ProGuard

If you are using ProGuard to obfuscate your release APK file, please add the following lines of code to your proguard configurations:

Test Integration Test your Integration

  • Run your Project on an Android device.
  • Ensure, test ads are displayed when the “loadModule” call is made in your App.
  • Once test ads are seen on your device, go to your Leadbolt Portal and set your App to “Live”
  • Once approved, you should see live ads in your App.

Congratulations! You have successfully integrated the Leadbolt SDK in your App

Troubleshooting Troubleshooting

  • Video and Interstitial Ads may not be available at all times in all countries. It is always best to test with your App in Test Mode in the Publisher Portal as Test Ads are generally always available.
  • You should check your Publisher Portal and ensure the relevant section is visible under your App. Use the “Add Section” button to add if not available.
  • You should check the SDK logs located in Logcat logs with the Tag “AppTracker”.
  • Always test the sample app provided to confirm any integration issues are SDK based.
  • The SDK has been tested to be compatible with Android Studio Version 3.1.3

Advanced Integration

Check Ad Availability Checking Ad Availability

Leadbolt SDK provides additional ability to the developers to check before hand if an Ad is available before displaying it to create a better user-experience in your App. To check if a Network or Direct Deal Ad is available please use the code below:

To check if a Rewarded Ad is available to be displayed, please use the code below:

Pass Additional Info Passing Additional Information

You can increase your App’s performance by optionally including the additional information below. This allows selected premium advertisers to display their Ads to your users. To pass this additional information, use the following methods BEFORE calling loadModuleToCache

Event Listeners Using Event Listeners

With Event listeners, you can closely follow the ad states throughout your App. Leadbolt SDK will trigger events at all important stages of the Ad life-cycle. To implement event listeners in your App, you must implement the AppModuleListener class.

Setup SDK to use Event Listeners

Before using any of the Event Listener methods, you will need to initialize your Event Listener object in your Project like so:

Now, set AppModuleListener in your onCreate method BEFORE calling AppTracker.startSession() like so:

Event Listener Methods


← Return to Help Center