Getting Started with the ironSource Android SDK

Before You Start
We support Android Operating Systems Version 3.0 (API level 11) and up.

Step 1. Add the ironSource SDK to Your Project

ironSource supports both Gradle dependencies and manual download mechanisms to integrate our SDK:

Gradle

 

  1. Add the following to your app’s build.gradle file inside repositories section:
    repositories {
        maven {
            url "https://dl.bintray.com/ironsource-mobile/android-sdk"
       }
    }
  2. Then add the following to the dependencies section:
    dependencies {
        compile 'com.ironsource.sdk:mediationsdk:6.6.7@jar'
    }

Manual Download

 

  1. Download the SDK here; unzip it and drop the mediationsdk_xxx.jar into the libs folder in your project:
    android-drag-jar-with-compile
  2. Make sure you add the following to your build.gradle file under the dependencies section:

    compile files('libs/mediationsdk-6.6.7.jar')

Step 2. Update AndroidManifest.xml

To update your AndroidManifest.xml, please complete the following steps:

  1. 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.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" />
  2. Google Play Services

    Amazon devices do not utilize Google Play Services. If you are building for the Amazon platform, skip the above step.
    1. Google Play Services in Your Android Manifest
      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" />
    2. Google Advertising ID
      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:
      Make sure you are using the latest Google Play Services version. Prior versions might not work on devices using Lollipop (API 21).

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 ironSource platform.

  • For Rewarded Video

    IronSource.setRewardedVideoListener(mRewardedVideoListener);
  • For Interstitial

    IronSource.setInterstitialListener(mInterstitialListener);
  • For Offerwall

    IronSource.setOfferwallListener(mOfferwallListener);
  • 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.
    IronSource.setLogListener(new LogListener() {
        @Override
        public void onLog(IronSourceLogger.IronSourceTag ironSourceTag, String s, int i) {
            
        }
    });

Step 5. Initialize the SDK

ironSource supports optional SDK settings such as UserID and Segments that must be configured before you initialize the SDK. See our guide on Additional SDK Settings for setup instructions.
Note: 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

You can initialize the SDK in two ways. We recommend the first method as it will fetch the specific ad units you define.
This method will init the specific ad units mentioned in the adUnits parameter:

/**
*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);

Alternatively, you can init the SDK as detailed below and the SDK will init the ad units you’ve configured on the ironSource platform:

IronSource.init(this, appKey);
 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 com.ironsource.sdk.controller.IronSourceWebView$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.ironsource.adapters.** { *;
}

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 ironSource 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 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.

You can read this article in: