AppLovin Android SDK 12.4.0 introduces a new set of SDK initialization APIs.
These deprecate the old way of initializing the SDK.
The new APIs provide a straightforward and organized way to initialize the SDK, while addressing issues with the old APIs.
You can find your SDK key in the Account > General > Keys section of the AppLovin dashboard.
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 configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration . builder ( " «SDK-key» " , this )
. setMediationProvider ( AppLovinMediationProvider . MAX )
// Perform any additional configuration/setting changes
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration. builder ( " «SDK-key» " , this )
. setMediationProvider (AppLovinMediationProvider.MAX)
// Perform any additional configuration/setting changes
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 )
// Initialize the SDK with the configuration
AppLovinSdk . getInstance ( this ) . initialize ( initConfig, new AppLovinSdk. SdkInitializationListener ()
public void onSdkInitialized ( final AppLovinSdkConfiguration sdkConfig )
class MainActivity : Activity()
override fun onCreate (savedInstanceState: Bundle?)
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration. builder ( " «SDK-key» " , this )
. setMediationProvider (AppLovinMediationProvider.MAX)
// Initialize the SDK with the configuration
AppLovinSdk. getInstance ( this ). initialize (initConfig) { sdkConfig ->
Example
Below is a sample integration that calls the new APIs.
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration . builder ( " «SDK-key» " , this )
. setMediationProvider ( AppLovinMediationProvider . MAX )
. setSegmentCollection ( MaxSegmentCollection . builder ()
. addSegment ( new MaxSegment ( 849 , Arrays .asList ( 1 , 3 ) ) )
// 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 ()
public void onSdkInitialized ( final AppLovinSdkConfiguration sdkConfig )
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration. builder ( " «SDK-key» " , this )
. setMediationProvider (AppLovinMediationProvider.MAX)
. setSegmentCollection (MaxSegmentCollection. builder ()
. addSegment ( MaxSegment ( 849 , listOf ( 1 , 3 )))
// 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 {
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 ->