我正在尝试在我的应用中展示奖励视频广告,每次尝试加载广告时,都会直接显示“无法加载广告”的方法。
对于我的手机,我收到错误:
W/Ads: Fail to instantiate adapter com.google.ads.mediation.chartboost.ChartboostAdapter
android.os.RemoteException
at com.google.android.gms.internal.zzgy.zzbx(Unknown Source)
at com.google.android.gms.internal.zzgy.zzbw(Unknown Source)
at com.google.android.gms.internal.zzgy.zzbu(Unknown Source)
at com.google.android.gms.internal.zzgz$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:387)
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:220)
at com.google.android.gms.ads.internal.reward.mediation.j.a(:com.google.android.gms.DynamiteModulesA:1140)
at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.DynamiteModulesA:19)
at com.google.android.gms.ads.internal.util.y.call(:com.google.android.gms.DynamiteModulesA:1055)
at com.google.android.gms.ads.internal.util.z.run(:com.google.android.gms.DynamiteModulesA:75)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
对于我正在使用的模拟器,我收到错误:
There was a problem getting an ad response. ErrorCode: 0
此外,我假设问题不在于admob,因为我已经实施了没有问题的横幅广告。我使用chartboost作为冥想。
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.reward.RewardItem;
import com.google.android.gms.ads.reward.RewardedVideoAd;
import com.google.android.gms.ads.reward.RewardedVideoAdListener;
import com.chartboost.sdk.Chartboost;
import com.chartboost.sdk.CBLocation;
import com.chartboost.sdk.ChartboostDelegate;
public class Settings extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, RewardedVideoAdListener {
SharedPreferences data;
final String filename = "Data";
Button btnAds;
Button btnResetData;
Button btnHelp;
long adtime;
private RewardedVideoAd mAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Chartboost.startWithAppId(this, "I have insterted my app id here", "and my app signature here");
Chartboost.onCreate(this);
setContentView(R.layout.activity_settings);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
btnAds = (Button) findViewById(R.id.btnAds);
btnResetData = (Button) findViewById(R.id.btnResetData);
btnHelp = (Button) findViewById(R.id.btnHelp);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
btnAds.setText("Loading ad...");
// Load an ad into the AdMob banner view.
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.setRequestAgent("android_studio:ad_template").build();
adView.loadAd(adRequest);
mAd = MobileAds.getRewardedVideoAdInstance(this);
mAd.setRewardedVideoAdListener(this);
loadRewardedVideoAd();
}
private void loadRewardedVideoAd() {
mAd.loadAd("I have inserted my app unit id here", new AdRequest.Builder().build());
}
}
我还获得了其他“奖励后”方法和“后退”方法
答案 0 :(得分:0)
看起来您正在尝试使用AdMob中介初始化Chartboost SDK。事实证明,这在我自己的项目中存在很大问题,因为SDK和SDK适配器彼此不能很好地协作。
您只需使用AdMob方法调用Chartboost,尝试单独初始化将导致Chartboost适配器失败。
这有点令人讨厌,因为AdMob只会在广告网络SDK中调用它们(这使得下载资产成为烦恼)但这就是AdMob的设计方式。
省略Chartboost startwith方法并用普通的AdMob方法替换它们以初始化AdMob SDK应解决此问题。