Getting started
Integrate the AppBrain SDK in your app in 5 minutes, using these three simple steps:
1. Add Gradle dependency
In your project’s build.gradle
file add:
repositories {
maven {
url 'https://swisscodemonkeys.github.io/appbrain-sdk/maven'
}
}
dependencies {
implementation 'com.appbrain:appbrain-sdk:+'
}
Note: older instructions included an @aar tag in the implementation line but this is wrong. You might get a warning “Couldn’t find dependency. Please check https://bit.ly/2LjzK2N for the correct AppBrain SDK setup.” To fix this, remove @aar from the gradle and rebuild your app.
2. Access your account
If you haven’t done so yet, create an AppBrain developer account to get access to the AppBrain developer dashboard and to register your app for the SDK.
3. Show ads
Show an interstitial ad with InterstitialBuilder
, for example when the user completes a level in your game:
private InterstitialBuilder interstitialBuilder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Preload the AppBrain interstitial. Settings the AdId is optional,
// but highly recommended. You can also create a custom AdId for your
// publisher app on our dashboard under "Ad settings".
interstitialBuilder = InterstitialBuilder.create()
.setAdId(AdId.LEVEL_COMPLETE)
.setOnDoneCallback(new Runnable() {
@Override
public void run() {
// Preload again, so we can use interstitialBuilder again.
interstitialBuilder.preload(getContext());
loadNextLevel();
})
.preload(this);
}
public void onLevelCompleted() {
interstitialBuilder.show(this);
}
For more details and examples, see Ad unit overview.
You’re done! For more detailed instructions see SDK setup, or the rest of the AppBrain SDK help pages.