Skip to content

Androidアプリへの全画面インタースティシャル広告の導入(Eclipse)

taro-yoshida edited this page Mar 28, 2017 · 23 revisions

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

SDKの更新

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

対応OS

Android4.1以上

利用準備

初期設定

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

プロジェクトの設定

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

ライブラリ追加

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

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.** { *; }

# 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.**

# nend
-keep class net.nend.android.** { *; }
-dontwarn net.nend.android.**

# imobile
-keep class jp.co.imobile.** {*;}
-dontwarn jp.co.imobile.**

-keepattributes EnclosingMethod

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" />

広告の設定

// 下記のインポートが必要です
import com.ad_stir.interstitial.AdstirInterstitial;
import com.ad_stir.interstitial.AdstirInterstitialListener;

private AdstirInterstitial adstirInterstitial;

// 全画面インタースティシャルのリスナーです
private AdstirInterstitialListener listener = new AdstirInterstitialListener() {
    @Override
    // 広告の読み込みが完了した際に再生を開始します。 
    public void onLoad(int spot_no) {
        if(adstirInterstitial.canShow()){
            adstirInterstitial.show();
        }
    }

    @Override
    public void onFailed(int spot_no) {}
    @Override
    public void onStart(int spot_no) {}
    @Override
    public void onStartFailed(int spot_no) {}
    @Override
    public void onFinished(int spot_no) {}
    @Override
    public void onClose(int spot_no) {}
};

@Override
// 広告の読み込み
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.xxxx);

	// このアクティビティで使用するスポットIDについて、初期化処理を行います。
	int[] spotIds = { 1, 2 };
	AdstirInterstitial.init(this, "MEDIA-xxxxxx", spotIds);
	// スポットIDごとにインスタンスを生成します。ここでは1についてのみ生成します。
	adstirInterstitial = new AdstirInterstitial(this, "MEDIA-xxxxxx", 1);
	// 上で定義したリスナーを登録します。
	adstirInterstitial.setAdstirInterstitialListener(listener);
	// 広告を読み込みます。
	adstirInterstitial.load();	
}

// 広告の一時停止等
@Override
protected void onResume() {
	if(adstirInterstitial != null) adstirInterstitial.resume();
	super.onResume();
}

@Override
protected void onPause() {
	if(adstirInterstitial != null) adstirInterstitial.pause();
	super.onPause();
}

@Override
protected void onDestroy() {
	if(adstirInterstitial != null) adstirInterstitial.destroy();
	super.onDestroy();
}

ライブラリ詳細

APIリファレンスをご覧ください。

よくある質問

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

開発版とリリース版のパッケージ名が異なる場合、一部の提携ネットワークで実績の取得が行われないことがございます。 その際は、リリース版と同じパッケージ名に変更いただいた上でテストいただくか、開発版とリリース版のパッケージ名が異なる旨を添えていただき、レポート数値について営業担当にお問い合わせください。

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内で正常に渡されております。ご安心ください。

Clone this wiki locally