【发布时间】:2020-03-09 18:33:46
【问题描述】:
我从一个月开始就在 Admob 创建了一个帐户,并从 2 天前开始添加付款方式。 成功展示广告的测试设备。但其他设备不显示任何错误代码:3
广告:广告加载失败:3
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private AdView adView;
private Button onePlayer, twoPlayer, exit;
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, getString(R.string.app_id));
MobileAds.initialize(this, initializationStatus -> {
});
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.instruction));
mInterstitialAd.loadAd(new AdRequest.Builder().addTestDevice("my-device-id").build());
mInterstitialAd.setAdListener(InterstitialListener);
adView = findViewById(R.id.adView);
adView.loadAd(new AdRequest.Builder().addTestDevice("my-device-id").build());
adView.setAdListener(adListener);
}
}
我为 InterstitialAd 创建了一个监听器
private AdListener InterstitialListener = new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
mInterstitialAd.show();
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Toast.makeText(getApplicationContext(), "errorCode " + errorCode + "", Toast.LENGTH_LONG).show();
}
@Override
public void onAdOpened() {
// Code to be executed when the ad is displayed.
}
@Override
public void onAdClicked() {
// Code to be executed when the user clicks on an ad.
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
}
@Override
public void onAdClosed() {
// Code to be executed when the interstitial ad is closed.
}
};
这是横幅 xml:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner">
</com.google.android.gms.ads.AdView>
注意:该应用尚未上传到商店!
我该如何解决这个问题?
【问题讨论】:
-
没有任何代码或错误日志就没有什么可做的。请考虑添加它们。
-
我添加了我的代码,你可以查看