Admob-sdk错误代码:0



我正在尝试在我的应用程序中添加admob广告。我遵循了谷歌教程,但没用。这是我的代码:

OnCreate()方法中:

   AdView adView = (AdView) this.findViewById(R.id.adView);
   AdRequest request = new AdRequest.Builder().build();
   adView.loadAd(request);

主要活动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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res/com.impact.ribony">

    <com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="48dip"
    app:pstsIndicatorColor  ="#0B0B16"
    app:pstsShouldExpand="true" />"
    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         />

    <android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_below="@+id/tabs">
    </android.support.v4.view.ViewPager>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-XXXXXXXX" />
</RelativeLayout>

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxxxx.xxxx"
    android:versionCode="8"
    android:versionName="1.0.7" >
    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />
    <application
        android:name=".Trackers"
        android:allowBackup="true"
        android:icon="@drawable/xxxx_top_icon"
        android:label="@string/app_name"
        android:theme="@style/CustomActionBarTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data 
            android:name="com.google.android.gms.analytics.globalConfigResource"
            android:resource="@xml/global_tracker" />
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
                    <meta-data
    android:name="android.app.default_searchable"
    android:value=".MainActivity" />
<intent-filter>
    <action android:name="android.intent.action.SEARCH" />
</intent-filter>
        </activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

日志文件:

11-10 12:00:22.592: W/Ads(1950): There was a problem getting an ad response. ErrorCode: 0
11-10 12:00:22.592: D/dalvikvm(1950): GC_FOR_ALLOC freed 1321K, 15% free 8406K/9788K, paused 2ms, total 3ms
11-10 12:00:22.600: W/Ads(1950): Failed to load ad: 0

是什么原因造成的?问题出在哪里?我不明白这个错误。

在我的案例中,代码是正确的,谷歌ply服务已经更新!

但我有一个新的admob帐户,有新的横幅&间隙id!

它花了2天&问题自动解决了&它开始显示广告…

尝试更新SDK管理器中的包。打开SDK管理器,然后检查EXTRA下有可用更新的所有包。

更新包后,在build.gradle(应用程序).中添加以下依赖项

compile 'com.google.android.gms:play-services:7.3.0'

最新更新