Android SDK

391 views 30/01/2018 Shay Karpeles 0

Getting Started

This document details the process of integrating YouAppi’s SDK with your Android app.

If you have any question you can email us

The basic steps of integration are:

  • Add our SDK AAR and dependencies to your project.
  • Init the SDK.
  • Load an ad.
  • Show an ad.


Minimum API level: 9, Android 2.3

Download YouAppi’s Android SDK

Our latest SDK version can be downloaded as a ZIP file from the following URL:

YouAppi Android SDK

The ZIP file contains:

  • SDK AAR file – youappiandroidsdk.aar
  • Demo app – youappi-sdk-android-demo-simple


  • Copy youappiandroidsdk.aar file to the apps\libs folder of your project.
  • Add the following to the project build.gradle file inside the repositories section:
    repositories {
        flatDir {
            dirs 'libs'
  • In your app build.gradle file add the following under dependencies section:
    dependencies {
        compile(name:'youappiandroidsdk', ext:'aar')
        compile('') {
            transitive = true;

Note: If Manifest Merger is disabled, the following items need to be added to the AndroidManifest.xml file:

  • Add AdActivity activity to <application> tag :
    <activity android:name=""
  • These permissions should be added if your app is running on older devices:
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Using the SDK

  • Initialize YouAppi SDK as soon as your app loads (for example your first activity) with the app token supplied by YouAppi:
    YouAPPi.init(context, "<YOUR_APP_TOKEN>");
  • Create an ad instance for one of YouAppi’s products:
    • Rewarded Video
    • Interstitial Video
    • Interstitial Ad
    YARewardedVideoAd rewardedVideoAd = YouAPPi.getInstance().rewardedVideoAd("test_rewarded_video_ad");
    YAInterstitialVideoAd interstitialVideoAd = YouAPPi.getInstance().interstitialVideoAd("test_interstitial_ad");
    YAInterstitialAd interstitialAd = YouAPPi.getInstance().interstitialAd("test_interstitial_ad");
  • Each instance is created with ad unit id. Ad unit id is an arbitrary string identifying the specific placement in which the ad is shown in your app.
  • Please note: ad unit id should be constructred only from letters (lowercase, uppercase), numbers and underscore.
  • Show an ad (for example, a rewarded video ad):;

Detailed example for Rewarded Video

Please note: this example is for rewarded video. Other products work in a similar way.

  • Create a rewarded video instance:
    YARewardedVideoAd rewardedVideoAd = YouAPPi.getInstance().rewardedVideoAd("test_rewarded_video_ad");
  • Add rewarded video event listener:

    rewardedVideoAd.setRewardedVideoAdListener(new YARewardedVideoAd.RewardedVideoAdListener() {
                public void onRewarded(String s) {
                public void onVideoStart(String s) {
                public void onVideoEnd(String s) {
                public void onVideoSkipped(String s, int i) {
                public void onCardShow(String s) {
                public void onCardClose(String s) {
                public void onCardClick(String s) {
                public void onLoadSuccess(String s) {
                public void onLoadFailure(String s, YAErrorCode yaErrorCode, Exception e) {
                public void onShowFailure(String s, YAErrorCode yaErrorCode, Exception e) {
                public void onAdStarted(String s) {
                public void onAdEnded(String s) {
  • Load rewarded video ad:
  • Once ad is loaded, the event onLoadSuccess is called and it can be shown by calling:;
  • Ad availability can also be checked by calling:


    If you’re using proguard in your application the following entries should be added to your proguard file:

    -keep class**{ *;}
    -keep class**{*;}
    -keep class**{*;}
    -keep interface**{*;}
    -keep enum**{*;}
    -keepclassmembers class * {
       @android.webkit.JavascriptInterface <methods>;

Logging and troubleshooting

after initializing the SDK you can set LogListener to get detailed log events from YouAppi’s SDK:

YouAPPi.getInstance().setLogListener(new Logger.LogListener()
       public void log(String tag, String message)
           // This will be called each time YouAppi SDK generates a log message.

Load and Show best practices

  • Make sure to init the SDK as soon as the app starts. It might take few seconds to complete the init process.
  • Make sure to load the ad about 30 seconds before you want to show it, since it takes time for the ad and assets to be prepared.
  • Make sure to show an ad as close as possible to loading it, in order to have a better fill rate and relevant ads.
  • Make sure not to wait too long before showing an ad, since it can be expired by the time you show it (expiry time is 5 hours).
  • Use ad event listeners in order to be notified when an ad is ready to be shown.
  • Use ad event listeners to handle load and show.
  • Loading an ad too many times without showing it might cause YouAppi servers to block the SDK from requests.