load admob在android应用程序中不起作用

load admob在android应用程序中不起作用,android,admob,Android,Admob,你好,我正在尝试向我的应用程序添加横幅,我以我认为合适的方式添加了单元id和应用程序id。。但是广告没有加载,它的位置保持空白。 我认为问题不在于横幅的位置,因为它的位置一直是空的,我试图在另一个活动中展示它,但我得到了相同的结果。 我在onCreate中有MainActivity.java,它包含以下内容: MobileAds.initialize(this, "ca-app-pub-*****************~**********"); mAdView = (AdView) fi

你好,我正在尝试向我的应用程序添加横幅,我以我认为合适的方式添加了单元id和应用程序id。。但是广告没有加载,它的位置保持空白。 我认为问题不在于横幅的位置,因为它的位置一直是空的,我试图在另一个活动中展示它,但我得到了相同的结果。 我在onCreate中有MainActivity.java,它包含以下内容:

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>


它现在可以正常工作,代码中没有任何更改,我想激活它需要几个小时

它现在可以正常工作,代码中没有任何更改,我想激活它需要几个小时

你是在真实的设备上还是在模拟器中检查?在真实的设备上!确保您以相同的方式设置广告大小和广告单元ID(即以XML或编程方式设置两者)。尝试在adRequestI中添加TestDevice(“您的设备ID”)。我将两者都设置为XML!!!你是在真实设备上还是在模拟器上检查?在真实设备上!确保您以相同的方式设置广告大小和广告单元ID(即以XML或编程方式设置两者)。尝试在adRequestI中添加TestDevice(“您的设备ID”)。我将两者都设置为XML!!!