Getting Started with the ironSource Android SDK
To begin monetizing your application with the ironSource SDK, follow these 3 easy steps:
- Add the SDK to your project
- Update AndroidManifest.xml
- Create Supersonic Instance
- Verify Your Integration
We support Android Operating Systems Version 3.0 (API level 11) and up.
Step 1. Add the ironSource SDK to Your Project
When upgrading from older SDK versions to the ironSource SDK 6.4.17+, you must update all mediation adapters.
ironSource supports both Gradle dependencies and manual download mechanisms to integrate our SDK:
For Gradle, follow these steps:
- Add the following to your app’s build.gradle file inside repositories section:
repositories { maven { url "https://dl.bintray.com/supersonic/android-sdk" } }
- Then add the following to the dependencies section:
dependencies { compile 'com.supersonic.sdk:mediationsdk:6.4.21@jar' }
For Manual Download:
- Download the SDK here; unzip it and drop the supersonic_sdk_xxx.jar into the libs folder in your Project:
- Make sure you add the following to your build.gradle file under the dependencies section:
compile fileTree(dir: 'libs', include: ['*.jar'])
Step 2. Update AndroidManifest.xml
To update your AndroidManifest.xml, please complete the following steps:
- Add the below code to your AndroidManifest.xml
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
Add the following activities inside the <application> tag in your AndroidManifest:
<activity android:name="com.supersonicads.sdk.controller.ControllerActivity" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" /> <activity android:name="com.supersonicads.sdk.controller.InterstitialActivity" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" android:theme="@android:style/Theme.Translucent" /> <activity android:name="com.supersonicads.sdk.controller.OpenUrlActivity" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" android:theme="@android:style/Theme.Translucent" />
Google Play Services
Add the following inside the <application> tag in your AndroidManifest:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
- Integrate Google Play Services
The ironSource SDK requires access to the Google Advertising ID in order to operate properly. See this guide on how to integrate Google Play Services.
Note: Note:
Make sure you are using the latest Google Play Services version. Prior versions might not work on devices using Lollipop (API 21).Amazon devices do not utilize Google Play Services. If you are building for the Amazon platform, skip the above step.
Step 3. Create Supersonic Instance
To create a Supersonic Instance you must implement the relevant code on application launch as well as during the application lifecycle.
- On Application Launch
//Import the Supersonic Class import com.supersonic.mediationsdk.sdk.Supersonic; import com.supersonic.mediationsdk.sdk.SupersonicFactory; public class YourActivity extends Activity { //Declare the Supersonic Mediation Agent private Supersonic mMediationAgent; //For example, add the following inside “onCreate()” method: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Get the mediation publisher instance mMediationAgent = SupersonicFactory.getInstance(); } }
- Application Lifecycle
Override the onPause(), onResume() methods in each of your activities to call the corresponding Supersonic methods as follows:protected void onResume() { super.onResume(); if (mMediationAgent != null) { mMediationAgent.onResume (this); } } protected void onPause() { super.onPause(); if (mMediationAgent != null) { mMediationAgent.onPause(this); } }
- Optional: To receive detailed log events, you can register to the log delegate. ironSource provides a log delegate that will allow you to receive detailed logs inside your application. These logs are also printed to the consul. Before initializing the SDK you should first register to the log delegate to detailed log events.
mMediationAgent.setLogListener (new LogListener() { @Override public void onLog (SupersonicLogger.SupersonicTag tag, String message, int logLevel) { } ))
Step 4. 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 may have implemented, navigate to this article.
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 com.supersonicads.sdk.controller.SupersonicWebView$JSInterface { public *; } -keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keep public class com.google.android.gms.ads.** { public *; } -keep class com.supersonic.adapters.** { *; }
Done!
You are now ready to start working with ironSource’s Ad Units and Mediation Tools.
What’s Next?
Once you’ve verified your integration with the Integration Helper, follow our integration guides and implement our Ad Units:
Interested in Mediation? Integrate our Rewarded Video or Interstitial Ads in your app and follow our Mediation articles.