Integration
This page shows you how to download, import, and configure the AppLovin MAX SDK.
Download the Latest 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 19 or above.
To receive release updates, subscribe to the AppLovin Android MAX SDK GitHub repository.
Gradle
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:+") ⋮}
ProGuard Rules
If you use ProGuard, note that the AppLovin MAX SDK and adapters come bundled with the required ProGuard rules in the AARs. Therefore, you do not need to add any additional ProGuard rules to your project.
Integrate Custom SDK Adapters
AppLovin Exchange (ALX) supports a custom adapter for LinkedIn. Integration instructions are below, and more information can be found here.
To install the adapter, add the following to your app-level build.gradle
file:
dependencies { implementation 'com.applovin.dsp:linkedin-adapter:+'}
dependencies { implementation ("com.applovin.dsp:linkedin-adapter:+")}
Enable Ad Review
To enable the MAX Ad Review service, add the following to your build.gradle
files:
Additions to Root-Level build.gradle
File
buildscript { 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:+") }}
Additions to App-Level build.gradle
File
apply 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.
Initialize the SDK
Create the SDK Initialization Configuration
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, with the exception of AppLovinSdkSettings
which contains mutable properties that can be changed during the lifetime of the app.
// Create the initialization configurationAppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»", this ) .setMediationProvider( AppLovinMediationProvider.MAX )// Perform any additional configuration/setting changes .build();
// Create the initialization configurationval initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»", this) .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 SDK
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»", this ) .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»", this) .setMediationProvider(AppLovinMediationProvider.MAX) .build()
// Initialize the SDK with the configuration AppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig -> // Start loading ads } }}
Example
Below is a sample integration:
// Create the initialization configurationAppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»", this ) .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 configurationAppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener(){ @Override public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig) { // Start loading ads }} );
// Create the initialization configurationval initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»", this) .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).settingssettings.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 configurationAppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig -> // Start loading ads}