Admob sdk错误代码:0

时间:2014-11-10 12:09:12

标签: android admob

我正在尝试在我的app中添加admob广告。我跟着Google教程,但它没有用。这是我的代码:

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

这可能是什么原因造成的?问题是什么 ?我没有理解这个错误。

2 个答案:

答案 0 :(得分:1)

就我而言,代码是正确的,google-ply-services已更新!

但是我正在使用新的横幅广告和新广告。插页式广告!

用了2天时间问题自动解决了它开始显示广告......

答案 1 :(得分:0)

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

更新软件包后,在build.gradle(app)中添加以下依赖项。

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