AndroidアプリへのAdExchangeインタースティシャル広告の導入(Eclipse) - united-adstir/AdStir-Integration-Guide-Android GitHub Wiki

このページは旧バージョンのAdStirSDKについてご説明したものです。
最新版は以下からご覧ください。
AndroidアプリへのAdExchangeインタースティシャル広告の導入

SDKの更新

SDKを更新する際はパッケージに含まれる全てのSDKを更新してください。 バージョンの異なるSDKをご利用の場合、正常に動作しない可能性があります。

対応OS

Android4.1以上

利用準備

初期設定

Google Play Servicesの設定、およびSDKの取得については初期設定をご覧ください。

プロジェクトの設定

Compile SDK Version は API18以上に設定してください。

ライブラリ追加

SDKの中にあるadstirwebview.jarとandroidwebviewmediation-videoreward-*.jar、同梱されている動画アドネットワークのSDK全てのファイルを、プロジェクトのlibsフォルダへ設置します。 library projectはインポートして、プロジェクトのProperty->Android->LibraryにAddしてください。

Google Play servicesのセットアップ

本SDKでは、Google Play servicesの機能を使用しているため、セットアップが必要です。 File -> Project Structure -> app -> Dependenciesより、**com.google.android.gms:play-services-ads:[ver.]**を追加してください。

AndroidManifest.xmlへの記述

ここの記述は、バージョンアップすることに内容が変化しますので、バージョンアップするたびに確認してください。

AndroidManifest.xmlへ以下の設定を追加します。

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

また、タグ内部に以下のActivityを定義します。

<activity android:name="com.jirbo.adcolony.AdColonyOverlay"
	android:configChanges="keyboardHidden|orientation|screenSize"
	android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyFullscreen"
	android:configChanges="keyboardHidden|orientation|screenSize"
	android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyBrowser"
	android:configChanges="keyboardHidden|orientation|screenSize"
	android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />

<activity android:name="com.applovin.adview.AppLovinInterstitialActivity" />
<activity android:name="com.applovin.adview.AppLovinConfirmationActivity" />

<activity android:name="com.ad_stir.videoincentive.AdstirFullscreenActivity"
	android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
	android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />

<activity
    android:name="jp.maio.sdk.android.AdFullscreenActivity"
    android:label="maiosdk"
    android:configChanges="orientation|screenLayout|screenSize|smallestScreenSize"
    android:hardwareAccelerated="true"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <intent-filter>
        <data android:scheme="jp.maio.sdk.android"/>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

<activity
    android:name="com.vungle.publisher.FullScreenAdActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>

<activity
    android:name="com.unity3d.ads.adunit.AdUnitActivity"
    android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    android:hardwareAccelerated="true"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
    android:name="com.unity3d.ads.adunit.AdUnitSoftwareActivity"
    android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    android:hardwareAccelerated="false"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

<activity
    android:name="jp.gmotech.smaad.video.ad.SmaAdVideoActivity"
    android:configChanges="orientation|screenLayout|screenSize|smallestScreenSize"
    android:hardwareAccelerated="true"
    android:label="SmaAD Video Android"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    <intent-filter>
        <data android:scheme="jp.gmotech.smaad.video.ad" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

<activity
    android:name="com.tapjoy.TJAdUnitActivity"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:hardwareAccelerated="true"
    android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
    android:name="com.tapjoy.mraid.view.ActionHandler"
    android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
    android:name="com.tapjoy.mraid.view.Browser"
    android:configChanges="orientation|keyboardHidden|screenSize" />
<activity
    android:name="com.tapjoy.TJContentActivity"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    android:hardwareAccelerated="true" />

<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

ProGuardの設定

ProGuardを使用しているアプリには以下の設定の追加をお願いいたします。

# adstir
-dontwarn com.ad_stir.**
-keep class com.ad_stir.** { *; }
-keep interface com.ad_stir.** { *; }

# google
-keep class com.google.android.gms.ads.** { *; }
-keep class android.support.customtabs.** { *; }

# adcolony
-dontwarn com.jirbo.adcolony.**
-keep class com.jirbo.adcolony.**{ *; }

# applovin
-dontwarn com.applovin.**
-keep class com.applovin.**.*

# unity-ads
-keepattributes SourceFile,LineNumberTable
-keepattributes JavascriptInterface
-keep class android.webkit.JavascriptInterface {
   *;
}
-keep class com.unity3d.ads.** {
   *;
}

# maio
-dontwarn jp.maio.**
-keep class jp.maio.** { *; }
-keep interface jp.maio.** { *; }

# vungle
-dontwarn com.vungle.**
-keep class com.vungle.** { *; }
-keep class javax.inject.*
-keepattributes *Annotation*
-keepattributes Signature
-keep class dagger.*

# smaad
-keep class jp.gmotech.smaad.video.ad.** { *; }

-keepattributes EnclosingMethod

# tapjoy
-keep class com.tapjoy.** { *; }
-keepattributes JavascriptInterface
-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.internal.**

広告の設定

// 下記のインポートが必要です
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
import com.google.android.gms.ads.doubleclick.PublisherInterstitialAd;

private PublisherInterstitialAd mPublisherInterstitialAd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dfp);

    mPublisherInterstitialAd = new PublisherInterstitialAd(this);

    // 実際に使用するAd Unit Idは営業担当者から別途お知らせ致します。
    mPublisherInterstitialAd.setAdUnitId("xxxxxxxxxxxxxxxxxxxxxxxx");
    mPublisherInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
        }

        @Override
        public void onAdLoaded() {
            mPublisherInterstitialAd.show();
        }

        public void onAdFailedToLoad(int errorCode) {
        }

        public void onAdLeftApplication() {
        }

        public void onAdOpened() {
        }
    });
    PublisherAdRequest adRequest = new PublisherAdRequest.Builder()
            .build();
    mPublisherInterstitialAd.loadAd(adRequest);
}

ライブラリ詳細

public final class PublisherInterstitialAd

インタースティシャル広告を呼び出すためのクラスです。 機能の詳細はGoogleの公式ドキュメントでご確認いただけます。 https://developers.google.com/android/reference/com/google/android/gms/ads/doubleclick/PublisherInterstitialAd

public abstract class AdListener

ロード完了などのコールバックを設定するクラスです。 各コールバックの詳細はGoogleの公式ドキュメントでご確認いただけます。 https://developers.google.com/android/reference/com/google/android/gms/ads/AdListener

よくある質問

レポートに表示回数が反映されません

アプリのパッケージ名が開発版の場合、そのパッケージ名に対して表示回数がカウントされてしまい、レポートに反映されません。テストの際にはパッケージ名をリリース版にした上でお願いいたします。

java.lang.ClassNotFoundExceptionが発生します

アダプタが正しく配置されていない場合、java.lang.ClassNotFoundExceptionが発生することがございます。上記のマニュアルをご覧いただき、アダプタ及びSDKが正常に配置されていることをご確認くださいますようお願いいたします。

Unable to find AppLovin SDK key. というエラーが出る

こちらのエラーは無視していただいて問題ありません。

Unable to find AppLovin SDK key. Please add meta-data android:name="applovin.sdk.key" android:value="YOUR_SDK_KEY_HERE" into AndroidManifest.xml.

AppLovinのSDKが出力している「AndroidManifest.xmlにAppLovinで発行したSDK KEYを設定してください」というエラーですが、SDK KEYはAdStir SDK内で正常に渡されております。ご安心ください。

⚠️ **GitHub.com Fallback** ⚠️