Android SDK Important Update Guide for 5.5.0+

Follow

This Guide aims to introduce the Important Update Issues For AdTiming Android SDK Version 5.5.0 and above. 

1.   Instructions

In the Android SDK Version 5.5.0 and Above, we have made some Important CHANGES. In addition to modifying the SDK’s Configuration and API to integrate AdTiming SDK, we have also Modularized the Adapters for mediation networks. Some ways of integration and SDK method will not be supported by the new version. Please kindly read this Guide according to the instructions for Android SDK integration to avoid errors during the ad.

For more integration information, please refer to AdTiming Online Help Center and follow Android SDK Integration, Ad Units and Mediation Network Guides for details.

  

2.   Integration overview

From Android SDK Version 5.5.0, the adapter of each ad network will be modularized, which means that you need to integrate NOT ONLY the SDK of AD Networks that you want to mediate BUT ALSO the adapters for those Networks.

For example, if you want to mediate Admob Ads by AdTiming SDK, you need to add Admob SDK as well as AdmobAdapter provided Independently by AdTiming to the libs of your project and pack them into APK together. Such way avoids integrating unnecessary codes to your app and reduces the size of APK. You can upgrade adapter only if Ad Network’s interface changes but not total SDK, which lead to decreased risk.

Follow the Android SDK Integration to integrate AdTiming's Rewarded Video, Interstitial or Banner/Native Ads into your application and refer to Add Mediation Networks to mediate ads from 10 leading Ad Networks.

 

The Ad Networks, its SDK versions and Ad Formats that are currently supported by our SDK is shown as following:

Ad Type

AdTiming

(5.5.3)

Admob

(17.2.1)

Facebook

(5.4.1)

Mopub

(5.8.0)

Applovin

(9.7.2)

Unity

(3.2.0)

Vungle

(6.4.11)

Tapjoy

(12.3.1)

Chartboost

(7.3.1)

Adcolony

(3.3.11)

 

 

 

 

 

 

 

 

 

 

 

 

Banner

Yes

Yes

Yes

Yes

No

No

No

No

No

No

 

 

 

 

 

 

 

 

 

 

Interstitial

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Yes

No

 

 

 

 

 

 

 

 

 

 

Native

Yes

Yes

Yes

Yes

No

No

No

No

No

No

 

 

 

 

 

 

 

 

 

 

Video

Yes

Yes

Yes

No

Yes

Yes

Yes

Yes

Yes

Yes

 

 

 

 

 

 

 

 

 

 

Interactive

Yes

No

No

No

No

No

No

No

No

No

 

 

 

 

 

 

 

 

 

 

 

 

3.   Configuration

Proguard Configuration

<!— v5.5.0 and later --> 
-dontwarn com.aiming.mdt.**.*
-dontwarn com.mopub.**.*

-dontoptimize
-dontskipnonpubliclibraryclasses
-keepattributes *Annotation*

 #adt
-keep class com.aiming.mdt.**{ *; }
-keep class com.mopub.** { *; }
-keepattributes *Annotation*,InnerClasses
-keepnames class * implements android.os.Parcelable {
        public static final ** CREATOR;
}

#R
-keepclassmembers class **.R$* {
    public static <fields>;
}

 

<!— before v5.5.0—>
-dontwarn com.aiming.mdt.**.*
-dontwarn com.adt.**.*
-dontwarn com.mopub.**.*

-dontoptimize
-dontskipnonpubliclibraryclasses
-keepattributes *Annotation*

#adt
-keep class com.admuing.** { *; }
-keep class com.aiming.mdt.** { *; }
-keep class com.adt.** { *; }
-keep class com.mopub.** { *; }

#R
-keepclassmembers class **.R$* {
    public static <fields>;
}



Use Multidex Configuration

Create multidex-config.pro in the module directory:

-keep class com.aiming.mdt.**{ *; }

 

4.   Initialization

<!— v5.5.0 and later --> 
import com.aiming.mdt.AdtAds;
import com.aiming.mdt.Callback;
...
...
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AdtAds.init(this, “Your AppKey", new Callback() {
            @Override
            public void onSuccess() {
                //init success
            }

            @Override
            public void onError(String message) {
                //init failed 
            }
}); }

 

<!— before v5.5.0—> 
import com.aiming.mdt.sdk.AdtAds;
...
...
public class DemoActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String appKey = "Your AppKey";
        AdtAds.init(this, appKey);
    }
}

 

5.   Ad Unit Integration Guides

5.1.  VideoAd

1.1 Create VideoAd object and register listener:

<!—v5.5.0 and later —> 
import com.aiming.mdt.video.VideoAd;
import com.aiming.mdt.video.VideoAdListener;
...
...
VideoAd videoAd = new VideoAd(activity, placementId, new VideoAdListener() {
    @Override
    public void onAdReady() {
        //videoAd load success
    }

    @Override
    public void onAdClicked() {
        //videoAd clicked
    }

    @Override
    public void onAdClosed(boolean isFullyWatched) {
        //videoAdClosed
        //is FullyWatched indicates whether the video was viewed completely
    }

    @Override
    public void onAdRewarded() {
        //videoAd rewarded
    }

    @Override
    public void onAdFailed(String error) {
        //videoAd load failed
    }
});

 

<!-before v5.5.0-> 
import com.aiming.mdt.sdk.ad.videoad.VideoAd;
import com.aiming.mdt.sdk.ad.videoad.VideoAdListener;
...
...
VideoAd videoAd = VideoAd.getInstance();
...
...
videoAd.setListener(new VideoAdListener() {
    @Override
    public void onAdReady(String placementId) {
         // videoAd is load success
    }

    @Override
    public void onAdClicked(String placementId) {
        // videoAd click
    }

    @Override
    public void onAdFailed(String placementId, int errorCode) {
        // videoAd fail
    }

    @Override
    public void onAdClosed(String placementId) {
        // videoAd close
    }

    @Override
    public void onAdRewarded(String placementId) {
        // videoAd Play to complete
    }
});

 

1.2 Load VideoAd:

<!- v5.5.0 and later -> 
videoAd.loadAd();

 

<!- before v5.5.0 -> 
videoAd.loadAd(activity, placementId);

 

1.3 Incentive VideoAd

<!-v5.5.0 and later -> 
videoAd.setExtId(String ExtId);

 

<!-before v5.5.0-> 
videoAd.loadAd(activity, placementId, extId);

 

1.4 Play VideoAd

<!- v5.5.0 and later -> 
if (videoAd != null && videoAd.isReady()) {
    videoAd.showAd();
}

Note: isReady() should be called on UI Thread

 

<!-before v5.5.0-> 
if (videoAd != null && videoAd.isReady(placementId)) {
    videoAd.showAd(activity, placementId);
}

 

1.5 Destroy VideoAd

<!- v5.5.0 and later -> 
/** It is recommended to invoke destroy method to release VideoAd object
when the Activity be destroyed. */
if (videoAd!=null){
    videoAd.destroy();
}

 

5.2.  InterstitialAd

2.1 Create InterstitialAd object and register listener:

<!- v5.5.0 and later -> 
import com.aiming.mdt.interstitial.InterstitialAd;
import com.aiming.mdt.interstitial.InterstitialAdListener; 
...
...
InterstitialAd interstitialAd = new InterstitialAd(activity, placementId, new InterstitialAdListener() {
    @Override
    public void onAdReady() {
        //interstitialAd load success
    }

    @Override
    public void onAdClicked() {
        //interstitialAd clicked
    }

    @Override
    public void onAdClosed() {
        //interstitialAd closed
    }

    @Override
    public void onAdFailed(String error) {
        //interstitialAd load failed
    }

});

 

<!-before v5.5.0-> 
import com.aiming.mdt.sdk.ad.interstitialad.InterstitialAd;
import com.aiming.mdt.sdk.ad.interstitialad.InterstitialAdListener;
...
...
InterstitialAd interstitialAd = InterstitialAd.getInstance();
 ...
...
 interstitialAd.setListener(new InterstitialAdListener() {
    @Override
    public void onAdReady(String placementId) {
         // interstitialAd is load success
    }

    @Override
    public void onAdClicked(String placementId) {
         // interstitialAd click
    }

    @Override
    public void onAdFailed(String placementId, int errorCode) {
        // interstitialAd fail
    }

    @Override
    public void onAdClosed(String placementId) {
        // interstitialAd close
    }
});

 

2.2 Load InterstitialAd

<!- v5.5.0 and later -> 
interstitialAd.loadAd();

 

<!-before v5.5.0-> 
interstitialAd.loadAd(activity,placementId);

 

2.3 InterstitialAd Display

<!- v5.5.0 and later -> 
if(interstitialAd != null && interstitialAd.isReady()){
    interstitialAd.showAd();
}

Note: isReady() should be called on UI Thread

 

<!-before v5.5.0-> 
if (interstitialAd != null && interstitialAd.isReady(placementId)) {
    interstitialAd.showAd(activity,placementId);
}

 

2.4 Destroy InterstitialAd

<!- v5.5.0 and later -> 
/** It is recommended to invoke destroy method to release InterstitialAd object
when the Activity be destroyed. */
if (interstitialAd!=null){
    interstitialAd.destroy();
}  

 

5.3.  NativeAd

3.1 Create NativeAd object and register listener:

<!- v5.5.0 and later -> 
import com.aiming.mdt.nativead.NativeAd;
import com.aiming.mdt.nativead.NativeAdListener;
...
...
NativeAd nativeAd = new NativeAd(activity, placementId, new NativeAdListener() {
    @Override
    public void onAdReady(AdInfo info) {
        //nativeAd load success
}

    @Override
    public void onAdClicked() {
        //nativeAd click
    }

    @Override
    public void onAdFailed(String error) {
        //nativeAd load failed
    }
});

 

<!-before v5.5.0-> 
import com.aiming.mdt.sdk.ad.nativead.NativeAd;
import com.aiming.mdt.sdk.ad.nativead.NativeAdListener;
...
...
NativeAd nativeAd = new NativeAd(placementId);
...
...
nativeAd.setListener(new NativeAdListener() {
    @Override
    public void onAdReady(AdInfo adInfo) {
        // nativeAd is load success
    }

    @Override
    public void onAdClicked() {
        // nativeAd clicked
    }

    @Override
    public void onAdFailed(int errorCode) {
         // nativeAd fail
    }
});

 

3.2 Load NativeAd:

<!- v5.5.0 and later -> 
nativeAd.loadAd();
<!-before v5.5.0 -> 
nativeAd.loadAd(context);

 

3.3 NativeAd Display and View Listener:

<!- v5.5.0 and later ->
import com.aiming.mdt.nativead.AdIconView;
import com.aiming.mdt.nativead.AdInfo;
import com.aiming.mdt.nativead.MediaView;
import com.aiming.mdt.nativead.NativeAd;
import com.aiming.mdt.nativead.NativeAdView;
...
...
private NativeAd nativeAd;
private NativeAdView nativeAdView;
private AdInfo mAdInfo;
private View adView;
private RelativeLayout adParent;
...
...
    adParent = this.findViewById(R.id.native_ad_container);
    // Get NativeAdView
    nativeAdView = new NativeAdView(NativeActivity.this);
...
...
    @Override
    public void onAdReady(AdInfo info) {
        //native ad load success
        mAdInfo = info;
    }
...
...
     // Get your native ad view style
    adView = View.inflate(this, R.layout.native_ad_layout, null);
    // set native ad title
    TextView title = adView.findViewById(R.id.ad_title);
    title.setText(mAdInfo.getTitle());

    // set native ad Call To Action Text
    Button btn = adView.findViewById(R.id.ad_btn);
    btn.setText(mAdInfo.getCallToActionText());
    MediaView mediaView = adView.findViewById(R.id.ad_media);
    AdIconView iconMediaView = adView.findViewById(R.id.ad_icon_media);

    adParent.removeAllViews();

    // Add your native ads view to NativeAdView
    nativeAdView.addView(adView);
    nativeAdView.setTitleView(title);
    nativeAdView.setMediaView(mediaView);
    nativeAdView.setAdIconView(iconMediaView);
    nativeAdView.setCallToActionView(btn);

    nativeAd.registerNativeAdView(nativeAdView);//important
    adView.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
    adView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(Gravity.CENTER);

    // Add nativeAdView to adParent view
    adParent.addView(nativeAdView, layoutParams);

R.id.native_ad_container code as following:

<RelativeLayout
    android:id="@+id/native_ad_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</RelativeLayout>

R.layout.native_ad_layout code as following:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/color_ad_bg">

<TextView
    android:id="@+id/ad_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerInParent="true"
    android:padding="10dp"
    android:text="title"
    android:textColor="@android:color/white" />

<com.aiming.mdt.nativead.AdIconView
    android:id="@+id/ad_icon_media"
    android:layout_width="250dp"
    android:layout_height="175dp"
    android:layout_below="@id/ad_title"
    android:layout_centerHorizontal="true" />

<com.aiming.mdt.nativead.MediaView
    android:id="@+id/ad_media"
    android:layout_width="250dp"
    android:layout_height="175dp"
    android:layout_below="@id/ad_icon_media"
    android:layout_centerHorizontal="true" />

<Button
    android:id="@+id/ad_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/ad_media"
    android:layout_centerInParent="true"
    android:padding="10dp"
    android:text="calltoaction"
    android:textAllCaps="false" />
</RelativeLayout>

 

3.4 Destroy NativeAd:

<!- v5.5.0 and later -> 
/** It is recommended to invoke destroy method to release NativeAd object
when the Activity be destroyed. */
@Override
protected void onDestroy() {
    if (nativeAd!=null){
        nativeAd.destroy();
    }
    super.onDestroy();
}

 

5.4.  InteractiveAd

4.1 Create InteractiveAd object and register listener:

<!- v5.5.0 and later -> 
import com.aiming.mdt.interactive.InteractiveAd;
import com.aiming.mdt.interactive.InteractiveAdListener;
...
...
InteractiveAd interactiveAd = new InteractiveAd(activity, placementId, new InteractiveAdListener() {
    @Override
    public void onAdReady() {
        //interactiveAd load success
    }

    @Override
    public void onAdClosed() {
        //interactiveAd closed
    }

    @Override
    public void onAdFailed(String error) {
        //interactiveAd load failed
    }

});

 

<!- before v5.5.0 -> 
import com.aiming.mdt.sdk.ad.interactivead.InteractiveAd;
import com.aiming.mdt.sdk.ad.interactivead.InteractiveAdListener;
...
...
InteractiveAd interactiveAd = InteractiveAd.getInstance();
...
...
interactiveAd.setListener(new InteractiveAdListener() {
    @Override
    public void onAdReady(String placementId) {
        // interactiveAd is load success
    }

    @Override
    public void onAdFailed(String placementId, int errorCode) {
        // interactiveAd fail
    }

    @Override
    public void onAdClosed(String placementId) {
        // interactiveAd close
        }
});

 

4.2 Load InteractiveAd:

<!- v5.5.0 and later -> 
interactiveAd.loadAd();

 

<!- before v5.5.0 -> 
interactiveAd.loadAd(context,placementId);

 

4.3 InteractiveAd Display

<!- v5.5.0 and later -> 
if(interactiveAd != null && interactiveAd.isReady()){
    interactiveAd.showAd();
}

 

<!- before v5.5.0 -> 
if (interactiveAd != null && interactiveAd.isReady(placementId)){
    interactiveAd.showAd(context,placementId);
}

 

4.4 Destroy InteractiveAd:

<!- v5.5.0 and later -> 
/** It is recommended to invoke destroy method to release InteractiveAd object
when the Activity be destroyed. */
if (interactiveAd!=null){
    interactiveAd.destroy();
}

  

5.5.  BannerAd

5.1 Create BannerAd object and register listener:

<!- v5.5.0 and later -> 
import com.aiming.mdt.banner.BannerAd;
import com.aiming.mdt.banner.BannerAdListener;
...
...
BannerAd banner = new BannerAd(activity, placementId, new BannerAdListener() {
    @Override
    public void onAdReady(View view) {
        //bannerAd load success
    }

    @Override
    public void onAdClicked() {
        //bannerAd clicked
    }

    @Override
    public void onAdFailed(String error) {
        //bannerAd load failed
    }
});

 

<!- before v5.5.0 -> 
import com.aiming.mdt.sdk.ad.bannerad.BannerAd;
import com.aiming.mdt.sdk.ad.bannerad.BannerAdListener;
...
...
BannerAd bannerAd = new BannerAd(context, placementId);
...
...
bannerAd.setListener(new BannerAdListener() {
    @Override
    public void onAdReady() {
        // bannerAd is load success
    }

    @Override
    public void onAdClicked() {
        // bannerAd click
    }

    @Override
    public onAdFailed(int errorCode) {
        // bannerAd failed
    }
});

 

5.2 Load BannerAd

<!- v5.5.0 and later -> 
banner.loadAd();

 

<!- before v5.5.0 -> 
bannerAd.loadAd();

 

5.3 BannerAd Display:

<!- v5.5.0 and later -> 
private RelativeLayout adParent; 
...
...
    adParent = this.findViewById(R.id.native_ad_container); 
...
...
    @Override
    public void onAdReady(View view) {
        // bannerAd is load success
        if (null != view) {
             ((ViewGroup) view.getParent()).removeView(view);
         }
        adParent.removeAllViews();
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);    
        adParent.addView(view, layoutParams);
    }

 

<!- before v5.5.0 -> 
private RelativeLayout adParent;
...
...
    adParent = this.findViewById(R.id.native_ad_container);
...
...
    @Override
    public void onAdReady() {
        // bannerAd is load success
        if (null != bannerAd.getParent()) {
            ((ViewGroup) bannerAd.getParent()).removeView(bannerAd);
        }
        adParent.removeAllViews();
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        adParent.addView(bannerAd, layoutParams);
    }

R.id.native_ad_container code as following:

<RelativeLayout
      android:id="@+id/native_ad_container"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">
</RelativeLayout>

 

5.4 Destroy BannerAd:

<!- no changes-> 
@Override
protected void onDestroy() {
    if (banner!=null){
        banner.destroy();
    }
    super.onDestroy();
}
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.