首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Admob sdk错误代码:0

Admob sdk错误代码:0
EN

Stack Overflow用户
提问于 2014-11-10 20:09:12
回答 2查看 4.2K关注 0票数 1

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

OnCreate()方法中:

代码语言:javascript
复制
   AdView adView = (AdView) this.findViewById(R.id.adView);
   AdRequest request = new AdRequest.Builder().build();
   adView.loadAd(request);

主要活动xml:

代码语言:javascript
复制
<?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>

清单:

代码语言:javascript
复制
<?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>

日志文件:

代码语言:javascript
复制
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

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

EN

回答 2

Stack Overflow用户

发布于 2015-05-17 12:28:37

在我的例子中,代码是正确的,google-ply-services已经更新了!

但是我有了一个新的admob账号和新的banner & interstitial id!

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

票数 1
EN

Stack Overflow用户

发布于 2015-05-13 22:45:58

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

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

代码语言:javascript
复制
compile 'com.google.android.gms:play-services:7.3.0'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26843507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档