安卓:AdMob的不工作 [英] Android: AdMob not working

查看:135
本文介绍了安卓:AdMob的不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的AdMob不会在我的应用程序显示。我每次调用 loadAd(..)我收到以下错误:

  

请求资源0x7f0b000e失败,因为它是复杂的。在谷歌   没有发现播放业务资源。检查项目配置,以确保资源被包括在内。   有一个问题得到一个广告响应。错误code:1

我搜索小时的时间解决这个问题,但没有发现任何东西,对我的作品!我下载的谷歌播放服务最新版本,并在我的项目preferences加入他们作为库

下面是我的code: 活动:

 公共类WelcomeActivity延伸活动{

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_welcome);

        //查找AD浏览报作为一种资源和负载的请求。
        AD浏览报AD浏览报=(AD浏览报)this.findViewById(R.id.welcomeAdView);

        AdRequest.Builder adRequestBuilder =新AdRequest.Builder();
        adRequestBuilder.addTestDevice(************);
        adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        AdRequest adRequest = adRequestBuilder.build();
        adView.loadAd(adRequest);
    }
 

}

布局的xml:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:广告=htt​​p://schemas.android.com/apk/res-auto
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    的xmlns:程序=htt​​p://schemas.android.com/apk/res/de.ms.fade
    机器人:ID =@ + ID /容器
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    工具:上下文=de.ms.fade.WelcomeActivity>

....等布局的东西.....

< RelativeLayout的
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =match_parent
    机器人:layout_alignParentBottom =真正的>

    < com.google.android.gms.ads.AdView
        机器人:ID =@ + ID / welcomeAdView
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        广告:adSize =大旗
        广告:adUnitId =酒吧 -  ***************/>
< / RelativeLayout的>

< / RelativeLayout的>
 

AndroidManifest.xml中:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=de.ms.fade
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <用途-SDK
        安卓的minSdkVersion =14
        机器人:targetSdkVersion =19/>

    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>

    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/图标
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@安卓风格/ Theme.Holo.Light>
        &所述;元数据
            机器人:名称=com.google.android.gms.version
            机器人:值=@整数/ google_play_services_version/>

        <活动
            机器人:名称=de.ms.fade.WelcomeActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:screenOrientation =画像>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
        ...更多活动...
        <活动
            机器人:名称=com.google.android.gms.ads.AdActivity
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
        < /活性GT;
    < /用途>

< /舱单>
 

解决方案

我没有发现任何问题,你的code /布局。问题可能是与广告单元标识

我会建议你尝试创建一个不同的广告单元标识

希望工程。

AdMob won't show in my app. Every time I invoke loadAd(..) I get the following errors:

Requesting resource 0x7f0b000e failed because it is complex. The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. There was a problem getting an ad response. ErrorCode: 1

I searched hours for a solution to this problem but haven't found anything that works for me! I downloaded the latest version of the Google Play Services and added them as library in my project preferences

Here is my code: Activity:

public class WelcomeActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_welcome);

        // Look up the AdView as a resource and load a request.
        AdView adView = (AdView) this.findViewById(R.id.welcomeAdView);

        AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
        adRequestBuilder.addTestDevice("************"); 
        adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        AdRequest adRequest = adRequestBuilder.build();
        adView.loadAd(adRequest);
    }

}

Layout 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"
    xmlns:app="http://schemas.android.com/apk/res/de.ms.fade"
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context="de.ms.fade.WelcomeActivity" >

.... other layout stuff .....

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true" >

    <com.google.android.gms.ads.AdView
        android:id="@+id/welcomeAdView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="pub-***************" />
</RelativeLayout>

</RelativeLayout>

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.ms.fade"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="de.ms.fade.WelcomeActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        ... some more activities ...
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
        </activity>
    </application>

</manifest>

解决方案

I don't find any issue with your code/layout. Issue could be with the Ads Unit Id.

I would suggest you to try creating a different Ads Unit Id

Hope it works.

这篇关于安卓:AdMob的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆