Android SDK Integration
As of ironSource SDK 7.3.0, the supported Kotlin version is 1.5.0+.
The download, use and access to the SDK is subject to the ironSource Platform Online Terms and Conditions. If you do not agree to the terms of ironSource Mobile SDK Publisher Online Terms & Conditions, do not download, access, or use the SDK, or the underlying services.
Step 1. Add the ironSource SDK to Your Project
As of ironSource SDK Version 6.16.0, ironSource SDK will be released as AAR.
Please make sure that you update the dependency section according to the information below.
Please note that Manifest Activities are included in the AAR.
ironSource SDK supports both Gradle dependencies and manual download mechanisms to integrate our SDK:
Gradle
- Add the following to your app’s build.gradle file inside repositories section:
repositories { maven { url 'https://android-sdk.is.com/' } }
- Then add the following to the dependencies section:
Please note that as of ironSource SDK Version 6.16.0 ironSource SDK will be released as AAR.dependencies { implementation 'com.ironsource.sdk:mediationsdk:7.3.0.1' }
Gradle version 7+
If you’re using Gradle version 7+, update your repository section on your settings.gradle file, instead of build.gradle. Please note the repository section should be included as part of the dependencyResolutionManagement section:
dependencyResolutionManagement {
repositories {
maven {
url 'https://android-sdk.is.com/'
}
}
}
Manual Download
- Download Android SDK Version 7.3.0.1
- Import the .AAR file as a library project.
- If using Android Studio, download the ironSource .AAR file and add as a dependency to your own module.
- Go to File ➣ New ➣ New Module ➣ Import .AAR and navigate to the location where the ironSource .AAR file has been downloaded.
- Note: ironSource Manifest Activities are included in the AAR.
- Make sure you add the following to your build.gradle file under the dependencies section:
implementation(name: 'mediationsdk-7.3.0.1', ext:'aar')
- As of ironSource SDK 7.0.4+ you are required to add the Kotlin JARs to your project. You can read more about Kotlin support here.
Optional: Manual JAR Integration
If you are using mediationsdk_xxx.jar in your project, you can still use the same configuration.
- Rename the new mediationsdk-xxx.aar to mediationsdk-xxx.zip.
- Extract the classes.jar
- rename it to mediationsdk_xxx.jar.
- Update AndroidManifext.xml
Update AndroidManifest.xml for Manual JAR Integration
To update your AndroidManifest.xml, please complete the following steps:
-
- Manifest Permissions
Add the following permissions to your AndroidManifest.xml file inside the manifest tag but outside the <application> tag:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- Manifest Activities and Provider
Add this section inside the <application> tag in your AndroidManifest:
<activity android:name="com.ironsource.sdk.controller.ControllerActivity" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" /> <activity android:name="com.ironsource.sdk.controller.InterstitialActivity" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" android:theme="@android:style/Theme.Translucent" /> <activity android:name="com.ironsource.sdk.controller.OpenUrlActivity" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" android:theme="@android:style/Theme.Translucent" /> <provider android:authorities="${
applicationId}. IronsourceLifecycleProvider" android:name="com.ironsource. lifecycle. IronsourceLifecycleProvider" />
- Manifest Permissions
Demo Application
The Integration Demo application demonstrate how to integrate the LevelPlay Mediation in your app.
Download Android Demo ApplicationStep 2. Google identifier permissions
- Add the Play Services dependencies into the dependencies block, to allow GAID and APP Set ID information to be retrieved.
Learn more about Google’s app set id here.dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.google.android.gms:play-services-appset:16.0.0' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation 'com.google.android.gms:play-services-basement:18.1.0' }
- Apps updating their target API level to 31 (Android 12) will need to declare a Google Play services normal permission in the manifest file as follows:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Read more about Google Advertising ID changes here.
Step 3. Override Your Activity Lifecycle Methods
Application Lifecycle
Override the onPause(), onResume() methods in each of your activities to call the corresponding ironSource methods as follows:
protected void onResume() { super.onResume(); IronSource.onResume(this); } protected void onPause() { super.onPause(); IronSource.onPause(this); }
Step 4. Set the Listeners
The ironSource SDK fires several events to inform you of your ad unit activity. To receive these events, register to the listener of the ad units you set up on the LevelPlay platform.
Make sure you set the listeners before initializing the SDK, to avoid any loss of information.
- For Rewarded Video
IronSource.setLevelPlayRewardedVideoListener(mLevelPlayRewardedVideoListener);
- For Interstitial
IronSource.setLevelPlayInterstitialListener(mLevelPlayInterstitialListener);
- For Offerwall
IronSource.setOfferwallListener(mOfferwallListener);
Step 5. Initialize the SDK
If you’re serving the Offerwall ad unit or using server-to-server callbacks to reward your users with our rewarded ad units, you must set the UserID.
Init the SDK
The SDK can be initialized in two ways:
- We recommend this approach as it will fetch the specific ad units you define in the adUnits parameter. Ad unit is a string array.
/** *Ad Units should be in the type of IronSource.Ad_Unit.AdUnitName, example */ IronSource.init(this, appKey, IronSource.AD_UNIT.OFFERWALL, IronSource.AD_UNIT.INTERSTITIAL, IronSource.AD_UNIT.REWARDED_VIDEO, IronSource.AD_UNIT.BANNER);
When using this init approach, you can now initialize each ad unit separately at different touchpoints in your app flow in one session.
//Rewarded Video IronSource.init(this, appKey, IronSource.AD_UNIT.REWARDED_VIDEO); //Init Interstitial IronSource.init(this, appKey, IronSource.AD_UNIT.INTERSTITIAL); //Init Offerwall IronSource.init(this, appKey, IronSource.AD_UNIT.OFFERWALL) //Init Banner IronSource.init(this, appKey, IronSource.AD_UNIT.BANNER);
- Alternatively, you can init the SDK as detailed below and the SDK will init the ad units you’ve configured on the LevelPlay platform:
IronSource.init(this, appKey);
Init Complete Callback
The ironSource SDK fires callback to inform you that the ironSource SDK was initialized successfully, for ironSource SDK 7.2.1+ . This listener will provide you an indication that the initialization process was completed, and you can start loading ads. The callback will be sent once per session, and will indicate the first initialization of the SDK.
IronSource.init(this, appKey,new InitializationListener) {
@Override public void onInitializationComplete() {
// ironSource SDK is initialized
}
}
For ProGuard Users Only
If you are using ProGuard with the ironSource SDK, you must add the following code to your ProGuard file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt):
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
#noinspection ShrinkerUnresolvedReference
#unity
-keep class com.ironsource.unity.androidbridge.** { *;}
-keep class com.google.android.gms.ads.** {public *;}
-keep class com.google.android.gms.appset.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
#adapters
-keep class com.ironsource.adapters.** { *; }
#sdk
-dontwarn com.ironsource.**
-dontwarn com.ironsource.adapters.**
-keepclassmembers class com.ironsource.** { public *; }
-keep public class com.ironsource.**
-keep class com.ironsource.adapters.** { *;
}
#omid
-dontwarn com.iab.omid.**
-keep class com.iab.omid.** {*;}
#javascript
-keepattributes JavascriptInterface
-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
Step 6. Verify Your Integration
The ironSource SDK provides an easy way to verify that your Rewarded Video Mediation integration was completed successfully. To verify your ironSource SDK integration as well as any additional Ad Networks you have implemented, simply add this method to your project:
IntegrationHelper.validateIntegration(activity);
For more details on the Integration Verification tool navigate to this article.
Done! You just integrated the ironSource SDK in your app.
You are now ready to start working with Ad Units and Mediation Tools.
- Follow our integration guides and implement our Ad Units:
Rewarded Video
Interstitial
Offerwall
Banner Mediation - Interested in Mediation? Integrate our Rewarded Video, Interstitial or Banner Ads in your app and follow our Mediation articles.
- Verify your integration with the Integration Helper.