负载AdMob没有在Android应用工作
问题描述:
你好我尝试横幅添加到我的应用程序,我增加单元ID和应用程序ID在适当的方式,我认为..但广告不加载,并将它放置保持空。 我认为这个问题是不是在横幅的地方,因为它的位置保持空的,我试图表明它在另一个活动,但我得到了相同的结果。 我有MainActivity.java中的onCreate它包含以下内容:负载AdMob没有在Android应用工作
MobileAds.initialize(this, "ca-app-pub-*****************~**********");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
activity_main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/outer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_above="@+id/adView"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@+id/adView"
/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-****************/**********">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
答
它的代码现在的工作没有任何改变,我认为它需要几个小时才能激活
你正在检查一个真实的设备或模拟器? – Munir
在真实的设备上! –
确保您以相同的方式设置广告尺寸和广告单元ID(即以XML或以编程方式同时设置)。 –