AdMob的插页式广告不加载 [英] AdMob interstitial ad not loading
问题描述
的插页式广告将不会在我的应用表明,我不知道该怎么办了。
注意: 我的应用程序是不是在谷歌的Play商店上市呢。我希望这不是造成故障。
我做了什么:
-
我对AdMob的网站上创建一个新的页内广告。
-
我已经加入谷歌发挥我的项目:
-
<活动
机器人:名称=com.google.android.gms.ads.AdActivity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
机器人:主题=@风格/ AppTheme.NoActionBar/>
&所述;元数据
机器人:名称=com.google.android.gms.version
机器人:值=@整数/ google_play_services_version/>
在谷歌Play服务版本是:
<整数NAME =google_play_services_version> 6171000< /整数GT;
- 我已经添加了
InterstitialAd
对象
-
进口com.google.android.gms.ads.AdListener;
进口com.google.android.gms.ads.AdRequest;
进口com.google.android.gms.ads.InterstitialAd;
私人InterstitialAd mInterstitialAd;
@覆盖
保护无效的onCreate(包savedInstance){
//
mInterstitialAd =新InterstitialAd(本);
mInterstitialAd.setAdUnitId(AD_UNIT_ID);
mInterstitialAd.setAdListener(mAdListener);
AdRequest.Builder建设者=新AdRequest.Builder();
mInterstitialAd.loadAd(builder.build());
}
- 和AD监听器:
-
私人AdListener mAdListener =新AdListener(){
@覆盖
公共无效onAdLoaded(){
super.onAdLoaded();
Functions.log(广告装!);
}
}
的方法: onAdLoaded()
不叫。我离开应用5分钟,但我没有得到回应。
我甚至试图强行显示()
findViewById(R.id.btn_testAd).setOnClickListener(新View.OnCliclIstener(){
@覆盖
公共无效的onClick(视图v){
mInterstitialAd.show();
}
});
我有什么在logcat中有:
的间隙没有加载。
有时候编程是一种痛苦。
我忘了申报的权限清单文件中。
<! - 用来请求旗帜,插播式广告。 - >
<使用-权限的Android:名称=android.permission.INTERNET对/>
&所述;! - 用于避免发送广告请求如果没有连接。 - >
<使用-权限的Android:名称=android.permission.ACCESS_NETWORK_STATE/>
<! - 所需的视频广告的权限。 - >
<使用-权限的Android:名称=android.permission.WRITE_EXTERNAL_STORAGE/>
The interstitial ad won't show in my application, I don't know what to do anymore.
Note: My app isn't listed in Google's Play store yet. I hope this isn't causing the fault.
What have I done:
I have created a new interstitial ad on the admob's site.
I have added Google Play to my project:
-
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@style/AppTheme.NoActionBar" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
The Google Play service version is:
<integer name="google_play_services_version">6171000</integer>
- I have added the
InterstitialAd
object
-
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
private InterstitialAd mInterstitialAd;
@Override
protected void onCreate(Bundle savedInstance) {
//
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(AD_UNIT_ID);
mInterstitialAd.setAdListener(mAdListener);
AdRequest.Builder builder = new AdRequest.Builder();
mInterstitialAd.loadAd(builder.build());
}
- And the ad listener:
-
private AdListener mAdListener = new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
Functions.log("Ad loaded !");
}
}
The method: onAdLoaded()
isn't called. I left the application for 5 minutes but I got no response.
I have even tried to force show()
findViewById(R.id.btn_testAd).setOnClickListener(new View.OnCliclIstener() {
@Override
public void onClick(View v) {
mInterstitialAd.show();
}
});
What have I got in the logcat:
The interstitial has not loaded.
Sometimes programming is a pain.
I forgot to declare the permissions in the manifest file.
<!-- Used to request banner and interstitial ads. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Used to avoid sending an ad request if there is no connectivity. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Required permissions for video ads. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
这篇关于AdMob的插页式广告不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!