Androidアプリへの動画視聴型インセンティブ広告の導入(Eclipse) - united-adstir/AdStir-Integration-Guide-Android GitHub Wiki
このページは旧バージョンのAdStirSDKについてご説明したものです。
最新版は以下からご覧ください。
Androidアプリへの動画視聴型インセンティブ広告の導入
SDKを更新する際はパッケージに含まれる全てのSDKを更新してください。 バージョンの異なるSDKをご利用の場合、正常に動作しない可能性があります。
Android4.1以上
Google Play Servicesの設定、およびSDKの取得については初期設定をご覧ください。
Compile SDK Version は API18以上に設定してください。
Project Build Target の API Level は 18以上に設定してください。
SDKの中にあるadstirwebview.jarとandroidwebviewmediation-videoreward-*.jar、同梱されている動画アドネットワークのSDK全てのファイルを、プロジェクトのlibsフォルダへ設置します。 library projectはインポートして、プロジェクトのProperty->Android->LibraryにAddしてください。
こちらの記述は、バージョンアップすることに内容が変化しますので、バージョンアップするたびに確認してください。
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" />
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.ad_stir.videoreward.AdstirVideoReward;
import com.ad_stir.videoreward.AdstirVideoRewardListener;
private boolean isRewarded = false;
// リスナーの定義
private AdstirVideoRewardListener listener = new AdstirVideoRewardListener() {
// 広告の読み込みが完了した際に再生を開始します。
public void onLoad(int spot_no) {
if(adstirVideoReward.canShow()){
adstirVideoReward.showRewardVideo();
}
}
public void onFailed(int spot_no) {};
public void onStart(int spot_no) {};
public void onStartFailed(int spot_no) {};
public void onFinished(int spot_no) {};
public void onReward(int spot_no) {
isRewarded = true;
};
public void onRewardCanceled(int spot_no) {};
public void onClose(int spot_no) {};
};
@Override
// 広告の読み込み
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xxxx);
// サーバーサイドで成果通知を受け取る場合、メディアユーザーIDを設定します。
// メディアユーザーIDは、AdstirVideoReward.init()の実行前にしか機能しません。
// ここでは例として、メールアドレスを指定していますが、任意のID(半角英数記号)が利用可能です。
AdstirVideoReward.setMediaUserID("[email protected]");
// このアクティビティで使用するスポットIDについて、初期化処理を行います。
int[] spotIds = { 1, 2 };
AdstirVideoReward.init(this, "MEDIA-xxxxxx", spotIds);
// スポットIDごとにインスタンスを生成します。ここでは1についてのみ生成します。
adstirVideoReward = new AdstirVideoReward(this, "MEDIA-xxxxxx", 1);
// 上で定義したリスナーを登録します。
adstirVideoReward.setAdstirVideoRewardListener(listener);
// 広告を読み込みます。
adstirVideoReward.load();
}
// 広告の一時停止等
@Override
protected void onResume() {
if(adstirVideoReward != null) adstirVideoReward.resume();
if(isRewarded) {
isRewarded = false;
Log.d(TAG, "Reward success.");
}
super.onResume();
}
@Override
protected void onPause() {
if(adstirVideoReward != null) adstirVideoReward.pause();
super.onPause();
}
@Override
protected void onDestroy() {
if(adstirVideoReward != null) adstirVideoReward.destroy();
super.onDestroy();
}
APIリファレンスをご覧ください。
AdStirでは、インセンティブ付与の通知を、任意のコールバックURLに行うことが可能です。
付与するインセンティブの単位と額は、任意の値に変更可能です。
AdstirVideoReward.setMediaUserID("[email protected]");
でユーザーIDを設定していない場合には通知されませんので、ご注意ください。
開発版とリリース版のパッケージ名が異なる場合、一部の対応提携ネットワークで実績の取得が行われないことがございます。 その際は、リリース版と同じパッケージ名に変更いただいた上でテストいただくか、開発版とリリース版のパッケージ名が異なる旨を添えていただき、レポート数値について営業担当にお問い合わせください。
アダプタが正しく配置されていない場合、java.lang.ClassNotFoundExceptionが発生することがございます。上記のマニュアルをご覧いただき、アダプタ及びSDKが正常に配置されていることをご確認くださいますようお願いいたします。
こちらのエラーは無視していただいて問題ありません。
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内で正常に渡されております。ご安心ください。