从我的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中设置adunit,Adtype为非页内广告,如下所示
@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
答案 0 :(得分:6)
该计划正在寻找MediationRewardedVideoAdAdapter的实施,这是ad.rewards.meditation的一个接口,它实现了MediationAdapter。
您正在使用:
com.vungle.mediation.VungleInterstitialAdapter
MediationAdapter is not a MediationRewardedVideoAdAdapter: com.vungle.mediation.VungleInterstitialAdapter
你的班级:
public class AndroidLauncher extends AndroidApplication
implements ActionResolver, GameHelper.GameHelperListener {
我不确定您在其他方法中实施适配器的位置,但是您说您也有非线性工作。看起来像使用丛林和乱舞之间的一些混乱。根据{{3}}。
compile files('libs/flurryAndroidDFPandAdMobMediationAdapter-5.0.0.r1.jar')
compile files('libs/VungleAdapter.jar')
您正在使用这两者,并且需要澄清您在每个AdRequest中使用的内容。
您可以像这样初始化AdView:
AdView admobView = new AdView(this);
而不是:
AdView admobView = createAdView();
您可以在创建AdRequest.Builder后将其添加到您的行中以运行测试。
AdRequest.Builder.addTestDevice("B6155B00A6A175A4D29AE13C0F0FBD7B");
同时检查您的api键是否设置为乱舞。这有一些信息可以在仪表板和代码中使用AdMob设置flurry适配器 vungle documentation
它还显示了添加适配器附加功能的有趣代码段:
FlurryAdapterExtras flurryAdapterExtras = new FlurryAdapterExtras();
AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtras(flurryAdapterExtras).build();
部分回答空指针异常的原始问题。
在onPause,onResume和onDestroy方法中放置空值检查。将初始化放在onCreate中可能是明智的,而不是将其放入单独的方法中。
在rewardedVideoAd
初始化之前,您可能出于某种原因调用了onPause方法。至少这样,你会感觉它是否会运行,它应该删除该错误(虽然可能会提供一个新的错误)。
为了便于阅读,请在oncreate方法之后放置以下所有方法。
@Override
protected void onPause() {
if(rewardedVideoAd!=null)
rewardedVideoAd.pause();
super.onPause();
.../...
}
@Override
protected void onResume() {
super.onResume();
if(rewardedVideoAd!=null)
rewardedVideoAd.resume();
.../...
}
}
@Override
public void onDestroy() {
if(rewardedVideoAd!=null)
rewardedVideoAd.destroy();
super.onDestroy();
accessTokenTracker.stopTracking();
}