Android admob ad不';t出现,并且没有错误

Android admob ad不';t出现,并且没有错误,android,admob,Android,Admob,我用admob广告创建了一个简单的应用程序,但广告没有出现,也没有错误,API级别为21 这是我的密码: xml文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@

我用admob广告创建了一个简单的应用程序,但广告没有出现,也没有错误,API级别为21

这是我的密码:

xml文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="76dp"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-2615894909216466/7973602032">
     </com.google.android.gms.ads.AdView>

</RelativeLayout>
logcat消息:

10-31 16:30:11.267: W/ScreenOrientationListener(1199): Removing an       inexistent observer!
10-31 16:30:11.383: W/Ads(1199): There was a problem getting an ad response. ErrorCode: 0
10-31 16:30:11.506: W/art(1199): Attempt to remove local handle scope entry from IRT, ignoring
10-31 16:30:11.547: W/AwContents(1199): onDetachedFromWindow called when already detached. Ignoring
10-31 16:30:11.647: W/art(1199): Attempt to remove local handle scope entry from IRT, ignoring
10-31 16:30:11.730: W/Ads(1199): Failed to load ad: 0
确保:

  • 您在清单文件中具有Internet权限 name=“banner\u ad\u unit\u id”>yourAppID
  • Java类中有一行代码:MobileAds.initialize(mainActivity.getApplicationContext(),“YourAppID”)
    有时广告不会从服务器加载,原因总是出现在logcat中,请注意并跟踪它,然后将其添加到帖子中。@我在帖子中添加了logcat如果您在emulator中测试应用程序,请尝试在真实设备上测试它。@Mohamed我在我的设备上尝试过,但仍然不起作用。
    10-31 16:30:11.267: W/ScreenOrientationListener(1199): Removing an       inexistent observer!
    10-31 16:30:11.383: W/Ads(1199): There was a problem getting an ad response. ErrorCode: 0
    10-31 16:30:11.506: W/art(1199): Attempt to remove local handle scope entry from IRT, ignoring
    10-31 16:30:11.547: W/AwContents(1199): onDetachedFromWindow called when already detached. Ignoring
    10-31 16:30:11.647: W/art(1199): Attempt to remove local handle scope entry from IRT, ignoring
    10-31 16:30:11.730: W/Ads(1199): Failed to load ad: 0