在我的 Admob 中,我为 Flurry 和 Vungle 设置了中介。当我请求广告时,我总是收到 Logcat 中提供的错误。
Could not instantiate mediation adapter: com.google.ads.mediation.flurry.FlurryAdapter.
MediationAdapter is not a MediationRewardedVideoAdAdapter: com.vungle.mediation.VungleInterstitialAdapter
摇篮
dependencies {
compile files('libs/FlurryAnalytics-6.2.0.jar')
compile files('libs/FlurryAds-6.2.0.jar')
compile files('libs/flurryAndroidDFPandAdMobMediationAdapter-5.0.0.r1.jar')
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/vungle-publisher-adaptive-id-3.3.4.jar')
compile files('libs/VungleAdapter.jar')
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services-ads:8.3.+'
compile 'com.google.android.gms:play-services-analytics:8.3.+'
compile 'com.google.android.gms:play-services-appindexing:8.3.+'
compile 'com.google.android.gms:play-services-appinvite:8.3.+'
compile 'com.google.android.gms:play-services-games:8.3.+'
compile 'com.google.android.gms:play-services-identity:8.3.+'
compile 'com.google.android.gms:play-services-plus:8.3.+'
compile project(':BaseGameUtils')
compile project(':facebook-android-sdk-4.8.1')
compile files('libs/AudienceNetwork.jar')
compile files('libs/FacebookAdapter.jar')
}
Admob 设置
我已经在 Admob 中设置了 adunit,其中 Adtype 为 Interstitial,如下所示
代码
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
@Override
protected void onPause() {
super.onPause();
if(rewardedVideoAd!= null)
rewardedVideoAd.pause();
socialShareType=null;
}
@Override
protected void onResume() {
super.onResume();
if(rewardedVideoAd!=null)
rewardedVideoAd.resume();
// Refresh the state of the +1 button each time we receive focus.
if(canShowGPlus1() && plusOneButton!=null) {
plusOneButton.initialize("https://developers.google.com/+", PLUS_ONE_REQUEST_CODE);
// plusOneButton.initialize("https://play.google.com/store/apps/details?id=com.game.puzzle.game.ballmania.android", PLUS_ONE_REQUEST_CODE);
}
}
@Override
public void onDestroy() {
if(rewardedVideoAd!=null)
rewardedVideoAd.destroy();
super.onDestroy();
accessTokenTracker.stopTracking();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
rateMe();
getActualScreenSize();
// Initialize the SDK before executing any other operations,
// especially, if you're using Facebook UI elements.
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
System.out.println("FacebookCallback : Success");
//fbShareNow();
}
@Override
public void onCancel() {
// App code
System.out.println("FacebookCallback : Cancel");
}
@Override
public void onError(FacebookException exception) {
// App code
System.out.println("FacebookCallback : Erroe");
}
});
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {
currentAccessToken=newAccessToken;
}
};
currentAccessToken = AccessToken.getCurrentAccessToken();
c=AndroidLauncher.this;
bld = new AlertDialog.Builder(this);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
//initialize(new MainGame(this), config);
// Create the layout
layout = new RelativeLayout(this);
// Do the stuff that initialize() would do for you
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
AdView admobView = createAdView();
layout.addView(admobView);
View gameView = initializeForView(new MainGame(this), config);
layout.addView(gameView);
showGPlus1(150, 150, 150, 150);
setContentView(layout);
if (isAppInstalledFromGooglePlay()) {
iabSetup();
}else{
Arrays.fill(gemPurchased, Boolean.FALSE);
}
initializeGameServices();
alarmSetup();
setInterestial();
setRewardedVideo();
//getHash();
}
private void setRewardedVideo() {
rewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
rewardedVideoAd.setUserId("userId");
AdRequest adRequest = new AdRequest.Builder().build();
rewardedVideoAd.loadAd(AD_UNIT_ID_REWARDED_VIDEO_AD, adRequest);
rewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
@Override
public void onRewardedVideoAdLoaded() {
System.out.println("onRewardedVideoAdLoaded()");
if (rewardedVideoAd.isLoaded()) {
rewardedVideoAd.show();
}
}
@Override
public void onRewardedVideoAdOpened() {
System.out.println("onRewardedVideoAdOpened()");
}
@Override
public void onRewardedVideoStarted() {
System.out.println("onRewardedVideoStarted()");
}
@Override
public void onRewardedVideoAdClosed() {
System.out.println("onRewardedVideoAdClosed()");
}
@Override
public void onRewarded(RewardItem rewardItem) {
System.out.println("onRewarded()");
}
@Override
public void onRewardedVideoAdLeftApplication() {
System.out.println("onRewardedVideoAdLeftApplication()");
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
System.out.println("onRewardedVideoAdFailedToLoad()");
}
});
}
日志猫:
01-31 19:38:05.795 6634-6634/com.game.puzzle.game.ballmania.android I/dalvikvm﹕ Could not find method android.security.NetworkSecurityPolicy.getInstance, referenced from method com.google.android.gms.ads.internal.t.e.a
01-31 19:38:06.085 6634-6735/com.game.puzzle.game.ballmania.android D/dalvikvm﹕ DexOpt: --- BEGIN 'ads1706048048.jar' (bootstrap=0) ---
01-31 19:38:06.285 6634-6735/com.game.puzzle.game.ballmania.android D/dalvikvm﹕ DexOpt: --- END 'ads1706048048.jar' (success) ---
01-31 19:38:06.285 6634-6735/com.game.puzzle.game.ballmania.android D/dalvikvm﹕ DEX prep '/data/data/com.game.puzzle.game.ballmania.android/cache/ads1706048048.jar': unzip in 0ms, rewrite 207ms
01-31 19:38:13.165 6634-6634/com.game.puzzle.game.ballmania.android I/Ads﹕ Starting ad request.
01-31 19:38:13.175 6634-6634/com.game.puzzle.game.ballmania.android I/Ads﹕ Use AdRequest.Builder.addTestDevice("B6155B00A6A175A4D29AE13C0F0FBD7B") to get test ads on this device.
01-31 19:38:16.665 6634-7074/com.game.puzzle.game.ballmania.android W/Ads﹕ Could not instantiate mediation adapter: com.google.ads.mediation.flurry.FlurryAdapter. null
01-31 19:38:16.715 6634-7074/com.game.puzzle.game.ballmania.android W/Ads﹕ Fail to instantiate adapter com.google.ads.mediation.flurry.FlurryAdapter
android.os.RemoteException
at com.google.android.gms.internal.zzev.zzah(Unknown Source)
at com.google.android.gms.internal.zzev.zzaf(Unknown Source)
at com.google.android.gms.internal.zzew$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:347)
at com.google.android.gms.ads.internal.l.a.d.a(SourceFile:94)
at com.google.android.gms.ads.internal.reward.c.b(SourceFile:194)
at com.google.android.gms.ads.internal.reward.mediation.h.a(SourceFile:53)
at com.google.android.gms.ads.internal.util.b.run(SourceFile:19)
at com.google.android.gms.ads.internal.util.r.call(SourceFile:52)
at com.google.android.gms.ads.internal.util.s.run(SourceFile:75)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
01-31 19:38:16.745 6634-7075/com.game.puzzle.game.ballmania.android W/Ads﹕ MediationAdapter is not a MediationRewardedVideoAdAdapter: com.vungle.mediation.VungleInterstitialAdapter
01-31 19:38:16.745 6634-7075/com.game.puzzle.game.ballmania.android W/Ads﹕ Fail to check if adapter is initialized.
android.os.RemoteException
at com.google.android.gms.internal.zzfd.isInitialized(Unknown Source)
at com.google.android.gms.internal.zzex$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:347)
at com.google.android.gms.ads.internal.l.a.g.g(SourceFile:621)
at com.google.android.gms.ads.internal.reward.mediation.a.a(SourceFile:83)
at com.google.android.gms.ads.internal.util.b.run(SourceFile:19)
at com.google.android.gms.ads.internal.util.r.call(SourceFile:52)
at com.google.android.gms.ads.internal.util.s.run(SourceFile:75)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
01-31 19:38:16.745 6634-6634/com.game.puzzle.game.ballmania.android W/Ads﹕ Failed to load ad: 3