加载admob在Android应用程序中不起作用

时间:2017-11-04 05:55:46

标签: android admob

你好,我试图添加横幅到我的应用程序我以适当的方式添加单位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>

1 个答案:

答案 0 :(得分:0)

它的工作现在没有改变代码中的任何内容,我认为它需要几个小时来激活