当我编译我的应用程序时,我始终会收到ERROR_CODE_NO_FILL的onAdFailedToLoad,这意味着当前Admob没有要提供的广告。两年来这从未发生过,如果我尝试从Play商店尝试使用当前版本,那么它将正确显示广告!
我阅读了许多关于stackoverflow的文章,但是我没有活跃的“专为家庭设计”,缺乏隐私政策。我什么都没改变!?
还有其他人与AdMob有关吗?
build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':SliderPreference')
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'com.google.android.gms:play-services-analytics:16.0.7'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}
apply plugin: 'com.google.gms.google-services'
代码
InterstitialAd mInterstitialAd;
@Override
protected void onPostCreate(Bundle savedInstanceState) {
MobileAds.initialize(context, BuildConfig.AD_APP_ID);
MobileAds.setAppMuted(true);
mInterstitialAd = new InterstitialAd (this);
mInterstitialAd.setAdUnitId(BuildConfig.AD_UNIT_ID);
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
Log.d("AD", "onAdFailedToLoad: "+String.valueOf(errorCode));
super.onAdFailedToLoad(errorCode);
}
@Override
public void onAdLoaded() {
Log.d("AD", "onAdLoaded: ");
super.onAdLoaded();
}
@Override
public void onAdClosed() {
if (!mAppSettings.isUnlocked(mAppSettings.PRODUCT_NOADS.productId,Tools.getSettings(context))) {
requestNewInterstitial();
}
promotionAndAdsFinished();
}
});
AdRequest adRequest = new AdRequest.Builder()
.build();
mInterstitialAd.loadAd(adRequest);
}