我正在尝试加载RewardedVideoAd
,但我收到错误代码3.我在logcat中收到此消息:
Fail to instantiate adapter com.google.ads.mediation.chartboost.ChartboostAdapter
android.os.RemoteException
at com.google.android.gms.internal.zzfz.zzao(Unknown Source)
at com.google.android.gms.internal.zzfz.zzan(Unknown Source)
at com.google.android.gms.internal.zzfz.zzal(Unknown Source)
at com.google.android.gms.internal.zzga$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:395)
at com.google.android.gms.ads.internal.mediation.client.d.a(:com.google.android.gms.DynamiteModulesA:94)
at com.google.android.gms.ads.internal.reward.c.b(:com.google.android.gms.DynamiteModulesA:215)
at com.google.android.gms.ads.internal.reward.mediation.h.a(:com.google.android.gms.DynamiteModulesA:1108)
at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.DynamiteModulesA:19)
at com.google.android.gms.ads.internal.util.u.call(:com.google.android.gms.DynamiteModulesA:1055)
at com.google.android.gms.ads.internal.util.v.run(:com.google.android.gms.DynamiteModulesA:75)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)*
我对此做了很多研究,但我没有得到任何解决方案。 任何帮助都将得到赞赏
我实施的代码是:
private RewardedVideoAd mRewardedVideoAd;
MobileAds.initialize(activity, getString(R.string.admob_app_id));
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(activity);
mRewardedVideoAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
private void loadRewardedVideoAd() {
synchronized (mLock) {
if (!mIsRewardedVideoLoading && !mRewardedVideoAd.isLoaded()) {
mIsRewardedVideoLoading = true;
Bundle extras = new Bundle();
extras.putBoolean("_noRefresh", true);
AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
.build();
mRewardedVideoAd.loadAd(getString(R.string.random_video), adRequest);
}
}
}
private void showRewardedVideo() {
if (mRewardedVideoAd.isLoaded()) {
randomClicked = -1;
mRewardedVideoAd.show();
}
}
@Override
public void onRewardedVideoAdLoaded() {
mIsRewardedVideoLoading = false;
}
@Override
public void onRewardedVideoAdOpened() {
}
@Override
public void onRewardedVideoStarted() {
}
@Override
public void onRewardedVideoAdClosed() {
loadRewardedVideoAd();
}
@Override
public void onRewarded(RewardItem rewardItem) {
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
mIsRewardedVideoLoading = false;
Log.i("rewarded_video", "Failed to Load Rewarded Video " + i);
loadRewardedVideoAd();
}
答案 0 :(得分:2)
首先,将其添加到清单文件
<activity android:name="com.chartboost.sdk.CBImpressionActivity"
android:excludeFromRecents="true"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:configChanges="keyboardHidden|orientation|screenSize" />
另外,不要忘记向Manifest文件添加必要的权限。
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
最后,如果您刚刚创建了帐户,或者刚刚对其进行了一些更改,则可能需要等待一段时间才能使更改生效,然后才能看到广告。