This page shows you how to download, import, and configure the AppLovin MAX SDK.
You can download the SDK through Gradle as a dependency. If you prefer to integrate manually, follow the instructions here.
The SDK requires the minSdkVersion to be 23 or above.
To receive release updates, subscribe to the AppLovin Android MAX SDK GitHub repository.
Add the following to your app-level build.gradle file:
repositories {
google()
mavenCentral()
⋮
}
dependencies {
implementation 'com.applovin:applovin-sdk:+'
⋮
}
repositories {
google()
mavenCentral()
⋮
}
dependencies {
implementation("com.applovin:applovin-sdk:+")
⋮
}If you use ProGuard, note that the AppLovin MAX SDK and adapters come bundled with the required ProGuard rules in the AARs. You do not need to add more ProGuard rules to your project.
The SDK collects the Google Advertising ID.
This requires the Android Advertising ID (AAID) module (com.google.android.gms:play-services-ads-identifier).
See Google Play services dependencies.
To enable the MAX Ad Review service, add the following to your build.gradle files:
build.gradle filebuildscript {
repositories {
maven { url 'https://artifacts.applovin.com/android' }
}
dependencies {
classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:+"
}
}
buildscript {
repositories {
maven { url = uri("https://artifacts.applovin.com/android") }
}
dependencies {
classpath ("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
}
}build.gradle fileapply plugin: 'applovin-quality-service'
applovin {
apiKey "«ad-review-key»"
}
plugins {
id("applovin-quality-service")
}
applovin {
apiKey = "«ad-review-key»"
}You can find your Ad Review Key in the Account > General > Keys section of the AppLovin dashboard.
Before you initialize the SDK, create an initialization configuration object for the SDK.
This object allows you to configure the properties that the SDK will initialize with.
These initialization properties are immutable, except AppLovinSdkSettings which contains mutable properties that can change during the lifetime of the app.
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»" )
.setMediationProvider( AppLovinMediationProvider.MAX )
// Perform any additional configuration/setting changes
.build();// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»")
.setMediationProvider(AppLovinMediationProvider.MAX)
// Perform any additional configuration/setting changes
.build()You can find your SDK key in the Account > General > Keys section of the AppLovin dashboard.
Initialize the AppLovin SDK with the initialization configuration object as early as possible (for example, in the onCreate() of the launch activity or Application class).
This maximizes how much time the SDK has to cache mediated networks’ ads, which results in a better user experience.
public class MainActivity extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»" )
.setMediationProvider( AppLovinMediationProvider.MAX )
.build();
// Initialize the SDK with the configuration
AppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener()
{
@Override
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig)
{
// Start loading ads
}
} );
}
}class MainActivity : Activity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»")
.setMediationProvider(AppLovinMediationProvider.MAX)
.build()
// Initialize the SDK with the configuration
AppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig ->
// Start loading ads
}
}
}Below is a sample integration:
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»" )
.setMediationProvider( AppLovinMediationProvider.MAX )
.setSegmentCollection( MaxSegmentCollection.builder()
.addSegment( new MaxSegment( 849, Arrays.asList( 1, 3 ) ) )
.build() )
.build();
// Configure the SDK settings if needed before or after SDK initialization.
val settings = AppLovinSdk.getInstance( this ).getSettings();
settings.setUserIdentifier( "«user-ID»" );
settings.setExtraParameter( "uid2_token", "«token-value»" );
settings.getTermsAndPrivacyPolicyFlowSettings().setEnabled( true );
settings.getTermsAndPrivacyPolicyFlowSettings().setPrivacyPolicyUri( Uri.parse( "«https://your-company-name.com/privacy-policy»" ) );
settings.getTermsAndPrivacyPolicyFlowSettings().setTermsOfServiceUri( Uri.parse( "«https://your-company-name.com/terms-of-service»" ) );
// Initialize the SDK with the configuration
AppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener()
{
@Override
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig)
{
// Start loading ads
}
} );// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»")
.setMediationProvider(AppLovinMediationProvider.MAX)
.setSegmentCollection(MaxSegmentCollection.builder()
.addSegment(MaxSegment(849, listOf(1, 3)))
.build()
)
.build()
// Configure the SDK settings if needed before or after SDK initialization.
val settings = AppLovinSdk.getInstance(this).settings
settings.userIdentifier = "«user-ID»"
settings.setExtraParameter("uid2_token", "«token-value»")
settings.termsAndPrivacyPolicyFlowSettings.apply {
isEnabled = true
privacyPolicyUri = Uri.parse("«https://your-company-name.com/privacy-policy»")
termsOfServiceUri = Uri.parse("«https://your-company-name.com/terms-of-service»")
}
// Initialize the SDK with the configuration
AppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig ->
// Start loading ads
}