Admob interstitial 在没有项目更改的情况下停止工作
Admob interstitial stopped working without project changes
我正在开发一个新应用程序并使用 Admob 投放插页式广告。我在 1-2 个月前对广告进行了编码,一切都很好。这些天我快要发布了,但我注意到广告可能在 2 周后就再也没有显示过。所以我决定调试。一切似乎都没有异常,但是 Admob SDK 总是报告未加载插页式广告,尽管 SDK 调用了回调 onAdLoaded
。
这是我的配置,我省略了无关的东西:
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.0.0'
}
}
dependencies {
compile "com.android.support:support-v4:18.0.+"
compile "com.google.android.gms:play-services-analytics:9.0.2"
compile 'com.google.android.gms:play-services-ads:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
这是具有奇怪行为的代码片段:
private com.google.android.gms.ads.InterstitialAd mInterstitialAd;
public void loadInterstitial() {
mInterstitialAd = new InterstitialAd(context);
mInterstitialAd.setAdUnitId(adUnitId);
mInterstitialAd.setAdListener(new AdListener()
{
@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.d(TAG, "is loaded = " + mInterstitialAd.isLoaded()); // FALSE!!!
}
}
}
public void showInterstitial() {
if(mInterstitialAd.isLoaded()) { // ALWAYS FALSE!!!
mInterstitialAd.show();
} else {
loadInterstitial(); // FAILED TO LOAD AD with error code = 1
}
}
当我调用 showInterstitial
时,在我调用 loadInterstitial
并且我可以看到 onAdLoaded
已被调用后,检查插页式广告是否加载 总是 returns false,并且再次调用 loadInterstitial
方法,现在 Admob SDK 给我错误,它无法加载错误代码 = 1 的广告。
这已经在多个设备上进行了测试,与广告或 Google Play 服务库相关的项目没有任何变化,它只是停止工作。
您知道问题出在哪里吗?或者我该怎么做才能更成功地调试这些错误?
非常感谢。
添加最新的gradle
compile 'com.google.android.gms:play-services-ads:9.2.1'
并删除
dependencies {
...
classpath 'com.google.gms:google-services:3.0.0'
}
同时删除插件
apply plugin: 'com.google.gms.google-services'
更新:
我想你不见了 AdRequest
?
InterstitialAd mInterstitialAd = new InterstitialAd(mContext);
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.setAdUnitId(mContext.getString(R.string.full_screen_id));
mInterstitialAd.loadAd(adRequest);
我正在开发一个新应用程序并使用 Admob 投放插页式广告。我在 1-2 个月前对广告进行了编码,一切都很好。这些天我快要发布了,但我注意到广告可能在 2 周后就再也没有显示过。所以我决定调试。一切似乎都没有异常,但是 Admob SDK 总是报告未加载插页式广告,尽管 SDK 调用了回调 onAdLoaded
。
这是我的配置,我省略了无关的东西:
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.0.0'
}
}
dependencies {
compile "com.android.support:support-v4:18.0.+"
compile "com.google.android.gms:play-services-analytics:9.0.2"
compile 'com.google.android.gms:play-services-ads:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
这是具有奇怪行为的代码片段:
private com.google.android.gms.ads.InterstitialAd mInterstitialAd;
public void loadInterstitial() {
mInterstitialAd = new InterstitialAd(context);
mInterstitialAd.setAdUnitId(adUnitId);
mInterstitialAd.setAdListener(new AdListener()
{
@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.d(TAG, "is loaded = " + mInterstitialAd.isLoaded()); // FALSE!!!
}
}
}
public void showInterstitial() {
if(mInterstitialAd.isLoaded()) { // ALWAYS FALSE!!!
mInterstitialAd.show();
} else {
loadInterstitial(); // FAILED TO LOAD AD with error code = 1
}
}
当我调用 showInterstitial
时,在我调用 loadInterstitial
并且我可以看到 onAdLoaded
已被调用后,检查插页式广告是否加载 总是 returns false,并且再次调用 loadInterstitial
方法,现在 Admob SDK 给我错误,它无法加载错误代码 = 1 的广告。
这已经在多个设备上进行了测试,与广告或 Google Play 服务库相关的项目没有任何变化,它只是停止工作。
您知道问题出在哪里吗?或者我该怎么做才能更成功地调试这些错误?
非常感谢。
添加最新的gradle
compile 'com.google.android.gms:play-services-ads:9.2.1'
并删除
dependencies {
...
classpath 'com.google.gms:google-services:3.0.0'
}
同时删除插件
apply plugin: 'com.google.gms.google-services'
更新:
我想你不见了 AdRequest
?
InterstitialAd mInterstitialAd = new InterstitialAd(mContext);
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.setAdUnitId(mContext.getString(R.string.full_screen_id));
mInterstitialAd.loadAd(adRequest);