Skip to content

Android

Adkit for ADOP: Android

Install

  1. Dowload and unzip the latest version of AdKit file.
  2. Copy the AdKit.gradle file to the path of project app.
  3. Add the followings to the build.gradle file of your project app:
    apply from: '(path to adkit.gradle file)/adkit.gradle'
    
    dependencies {
            // ...(skip)
    
            // add the AdKit library
            implementation "com.com2us.android:hive-adkit-adop:1.4.6"
    }
    

Setting

Add AdMobId, which is formatted in ca-app-pub-XXXXX~YYYYY, and ADOP APP_KEY to the AndroidManifest.xml file generated in the Android project. ADOP APP_KEY can be found in Account Management > My Information > Details after logging in to ADOP Insight.

<application>
        <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-XXXXX~YYYYY"/>
    <meta-data
        android:name="com.google.android.gms.ads.AD_MANAGER_APP"
        android:value="true"/>
    <meta-data
        android:name="com.adop.sdk.APP_KEY"
        android:value="6933aab2-7f78-11ed-a117-XXXXXXXXX"/>
    </application>

How to use

ADOP Proguard settings

If you are using Proguard, add the ADOP Proguard Settings as below.

  -keep class com.adop.sdk.** { *; }
  -keep class ad.helper.openbidding.** { *; }
  -keep class com.adop.sdk.adapter.**{ *; }
  -keepnames class * implements java.io.Serializable
  -keepclassmembers class * implements java.io.Serializable {
      static final long serialVersionUID;
      private static final java.io.ObjectStreamField[] serialPersistentFields;
      !static !transient ;
      private void writeObject(java.io.ObjectOutputStream);
      private void readObject(java.io.ObjectInputStream);
      java.lang.Object writeReplace();
      java.lang.Object readResolve();
  }
  -keepclassmembers class * {
      @android.webkit.JavascriptInterface ;
  }

  # Pangle
  -keep class com.bytedance.sdk.** { *; }
  -keep class com.bykv.vk.openvk.component.video.api.** { *; }

  # Tapjoy
  -keep class com.tapjoy.** { *; }
  -keep class com.moat.** { *; }
  -keepattributes JavascriptInterface
  -keepattributes *Annotation*
  -keep class * extends java.util.ListResourceBundle {
  protected Object[][] getContents();
  }
  -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
  public static final *** NULL;
  }
  -keepnames @com.google.android.gms.common.annotation.KeepName class *
  -keepclassmembernames class * {
  @com.google.android.gms.common.annotation.KeepName *;
  }
  -keepnames class * implements android.os.Parcelable {
  public static final ** CREATOR;
  }
  -keep class com.google.android.gms.ads.identifier.** { *; }
  -dontwarn com.tapjoy.**

Test ad key in ADOP

Using a test ad key that ADOP issued is required.

var bannerZoneId = "944fe870-fa3a-4d1b-9cc2-38e50b2aed43"
var interstitialZoneID = "e9acd7fc-a962-40e4-aaad-9feab1b4f821"
var rewardVideoZoneId = "7d9a2c9e-5755-4022-85f1-6d4fc79e4418"
var appOpenAdZoneId = "33906f96-dae8-4790-8ce4-d1f287ba00b2"

Initialize AdKit

Perform AdKit initialization.

When performing a reset, if you are in the European and UK (EEA & UK) regions, a GDPR consent pop-up will be automatically displayed. In other regions, a reset is performed immediately.

  • If your game targets the EEA & UK region, make sure your GDPR consent pop-up is set up according to the GDPR messaging guide.
import com.com2us.hive.adkit.*

// Commercial
AdKit.InitializeWithShowGDPRConsent(this.activity, false, null)

// GDPR EEA test mode
AdKit.InitializeWithShowGDPRConsent(this.activity, true, gdprTestDeviceId)

Delivering the user's additional information can be included when a Analytics log happens, and the data is passed in JSONObject type.

val data = JSONObject()
data.put("level", 1)
data.put("gold",100)
AdKit.SetAdditionalInfo(data)

RewardVideo type

Rewardedvideo type ads reward a user who watched a video for a period of time, and is able to load one ad at a time.

// RewardVideo Instance Create
var rewardVideo:RewardVideo? = null
rewardVideo = RewardVideo.Initialize(this.activity, rewardVideoZoneId, object : EventHandlers() {
   override fun onAdLoaded() {}
   override fun onAdOpening() {}
   override fun onAdClosed() {}
   override fun onAdFailed() {}
   override fun onAdClick() {}
   override fun onAdReward() {}
})
// RewardVideo Load
rewardVideo?.LoadAd("NativeRewardVideo-Load")
// RewardVideo Show
rewardVideo?.Show("NativeRewardVideo-Show")

Also, adPlacementInfo can be passed as a string that is set at the time of successful Load or exposing an ad through Show.

Interstitial type

Interstitial type ads use full-screen that cover the interface of game.

// Interstitial Instance Create
var interstitial:Interstitial? = null
interstitial = Interstitial.Initialize(this.activity, interstitialZoneId, object : EventHandlers() {
   override fun onAdLoaded() {}
   override fun onAdOpening() {}
   override fun onAdClosed() {}
   override fun onAdFailed() {}
   override fun onAdClick() {}
})
// Interstitial Load
interstitial?.LoadAd("NativeInterstitial-Load")
// Interstitial Show
interstitial?.Show("NativeInterstitial-Show")

Also, adPlacementInfo can be passed as a string that is set at the time of successful Load or exposing an ad through Show.

Adaptive Banner type

Adaptive Banner type ads are a type of rolling banner that occupies a spot on screen. You can adjust the banner position with the BannerPosition or an yPos value. If you provide yPos to adjust the banner position, the banner will be aligned at the bottom of the screen and then will move up by the yPos value you specify.

// the example codes using the BannerPosition 
var adaptiveBanner: AdaptiveBanner? = null

// Create AdaptiveBanner Instance at Top of View
adaptiveBanner = AdaptiveBanner.Initialize(this.activity, bannerZoneId, AdaptiveBanner.BannerPosition.Top, object : EventHandlers() {
   override fun onAdLoaded() {}
   override fun onAdOpening() {}
   override fun onAdClosed() {}
   override fun onAdFailed() {}
   override fun onAdClick() {}
})

// Create AdaptiveBanner Instance at Bottom of View
adaptiveBanner = AdaptiveBanner.Initialize(this.activity, bannerZoneId, AdaptiveBanner.BannerPosition.Bottom, object : EventHandlers() {
   override fun onAdLoaded() {}
   override fun onAdOpening() {}
   override fun onAdClosed() {}
   override fun onAdFailed() {}
   override fun onAdClick() {}
})

// AdaptiveBanner Load & Automatic show
adaptiveBanner?.LoadAd("NativeAdaptiveBanner-Load")

// Destroy AdaptiveBanner
adaptiveBanner?.Destroy()

// This example shows adjusting the banner position with specifiying the yPos value.
var adaptiveBanner: AdaptiveBanner? = null
adaptiveBanner = AdaptiveBanner.Initialize(this.activity, bannerZoneId, yPos, object : EventHandlers() {
   override fun onAdLoaded() {}
   override fun onAdOpening() {}
   override fun onAdClosed() {}
   override fun onAdFailed() {}
   override fun onAdClick() {}
})

// Banner Load
adaptiveBanner?.LoadAd("NativeAdaptiveBanner-Load")

// Banner Show
adaptiveBanner?.Show("NativeAdaptiveBanner-Show")

// Banner Hide
adaptiveBanner?.Hide()

// The position is adjusted following the yPos value.
adaptiveBanner?.setPosition(yPos)

Also, adPlacementInfo can be passed as a string that is set at the time of successful Load or exposing an ad through Show.

AppOpen type ads

A type that exposes an ad when the app state changes from background to foreground.

// Create AppOpenAd Instance
var appOpenAd: AppOpenAd? = null
appOpenAd = AppOpenAd.Initialize(this.activity, appOpenAdZoneId, object : EventHandlers() {
     override fun onAdLoaded() {}
     override fun onAdOpening() {}
     override fun onAdClosed() {}
     override fun onAdFailed() {}
})

// Automatically load & show AppOpenAd when the app comes to the foreground
appOpenAd?.LoadAd("NativeAppOpen-Load")

// Destroy AppOpenAd
appOpenAd?.Destroy()

Test ads

It is important for advertiser not to be charged when test ad is clicked in development. If you click ads too much out of test mode, it is regarded as invalid action. Therefore, be aware not to be a target account to report. Refer to the Google Developers to use a test ad.

Uninstall

Restore the files set during installation to their original state.