Android & Amazon


Before you begin:

  • Have you signed up for a Chartboost account?
  • Did you add an app to your dashboard?
  • Amazon integration uses the same SDK as Android. These integration instructions apply to games for Google Play or the Amazon App Store.
  • Chartboost Sample App is available here.
Publishers should call the addDataUseConsent API from the Chartboost SDK and pass in the appropriate value for whether consent exists, does not exist, or is unknown. Publishers are required as part of Terms of Service to obtain the consent from their users before Chartboost will process any personal data and pass it to the Chartboost SDK via the above method. This method should be called before startWithAppId.
Learn more about privacy methods here and Behavioral Targeting here.

Requirements and Optional Permissions

  • The Chartboost SDK requires API level 21 (Android OS 5) or higher.
  • The Chartboost Android SDK requires the use of AndroidX.
  • Required permission: android.permission.INTERNET
  • Required permission: android.permission.ACCESS_NETWORK_STATE
  • Optional (but recommended) permission: android.permission.READ_PHONE_STATE Allows the SDK to handle calls that interrupt video playback.

Add Chartboost repository and dependencies to your Gradle file.

  • To integrate Chartboost, add this code to your Android Gradle file:
Copied to clipboard

Add the Google Play Services Library as a dependency of your project. When you use our latest SDK, you will need “play-services-base” and “play-services-ads-identifier”.

  • The Google Play Services library has its own set of integration instructions, including additions to your Android Manifest and ProGuard configuration.
  • Follow these setup instructions from Google.
  • After following Google’s instructions to integrate the Play Services Library you should find something similar to the following two lines in your build.gradle file:
Copied to clipboard

If you display Chartboost ads in any activity that supports different orientations, add the following attribute to those activities in AndroidManifest.xml.

Copied to clipboard
This helps smoothen video playback during orientation changes.

Import the Chartboost SDK into any activity that uses Chartboost.

Copied to clipboard
Copied to clipboard

Initialize Chartboost SDK

  • startWithAppId doesn’t require Activity anymore. From version 8.0.1+ context should be passed instead.
Copied to clipboard
startWithAppId must always be called during hard and soft bootups within the first few seconds of your app launching, regardless of any other actions or user interaction within your app.
Publishers should call the addDataUseConsent API from the Chartboost SDK and pass in the appropriate value for whether consent exists, does not exist, or is unknown. Publishers are required as part of Terms of Service to obtain the consent from their users before Chartboost will process any personal data and pass it to the Chartboost SDK via the above method. This method should be called before startWithAppId.

Add your app ID and app signature.

Chartboost App ID is a unique App identifier in our systems, therefore it is required to use a different Chartboost App ID per each app.

To show a static or video interstitial ad:

Create interstitial object without mediation object:
Copied to clipboard

Create interstitial with mediation object:

Copied to clipboard

Cache interstitial:

Copied to clipboard
Show interstitial:
Copied to clipboard
Do not call showInterstitial directly after cacheInterstitial for the same location, or the SDK will fail silently.
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

To show a rewarded video ad:

Create rewarded object without mediation object:
Copied to clipboard

Create rewarded with mediation object:

Copied to clipboard

Cache rewarded:

Copied to clipboard
Show rewarded:
Copied to clipboard
We strongly recommend that you cache your interstitials before showing them. Learn more about caching ▶
Prefetched videos (in total) only take up 30-50MB, even when you are using mediation.

To show a banner ad:

Create banner object without mediation object:
Copied to clipboard

Create banner object with mediation :

Copied to clipboard
Attach banner to the holder. Banner object is extending FrameLayout and needs to be attached to the view to be displayed at the screen.
Copied to clipboard

Cache banner:

Copied to clipboard
Show banner:
Copied to clipboard
If you wish to remove the banner from view, use:
Copied to clipboard
Banner ads are not supported for Amazon integrations.
To make the banner ad show, first create it (detailed here), and then call the delegate method.

Test your integration.


Check the SDK icon in the Chartboost dashboard.

  • Go to your app’s App Settings > Basic Settings in your dashboard.
  • When our servers successfully receive a bootup call from our SDK using your app ID, the SDK icon underneath your app’s icon will turn from gray to green.

w00t! You just integrated the Chartboost SDK into your app!

Now you can start a campaign ▶


Check out more Chartboost SDK features


You might also like…
  • Error codes: Common problems and their solutions when integrating the SDK for Android.
▲ Back to top

Last Updated on November 8, 2022