com.google.ads.AdView未能实例 [英] com.google.ads.AdView failed to instantiate

查看:164
本文介绍了com.google.ads.AdView未能实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用AdMob的SDK,并添加外部jar.In XML我指定了

I have used admob sdk and added as external jar.In xml i have specified

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView android:id="@+id/headerfield"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
<ListView android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<com.google.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"    
    ads:adUnitId="Publisher Id"
    ads:loadAdOnCreate="true" />    
</LinearLayout>

清单

<activity android:name="com.google.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation"/>

但在图形模式下它给我一个错误日志:

But in graphical mode its giving me a error log:

com.google.ads.AdView - the following class could not be instantiated. 

在程序的表现

您必须AdActivity在AndroidManifest.xml中声明与configChanges。

You must have AdActivity declared in AndroidManifest.xml with configChanges.

推荐答案

在<一个href="https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals#adactivity">documentation,你需要包括附加configChanges在你的活动(假设你使用4.3.1或更高版本):

From the documentation, you'll need to include additional configChanges in your activity (assuming you're using 4.3.1 or higher):

<activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

如果您遇到其中,屏幕尺寸和smallestScreenSize不被认可的问题,你就必须编译aganist的Andr​​oid 3.2或更高版本。看看这个<一href="http://googleadsdeveloper.blogspot.com/2011/11/migrating-to-v431-of-admob-sdk-for.html">migration博客文章上下车的4.1.1更新至新版本的详细信息(同样适用于移动到6.0.0一样)。

If you run into issues where screenSize and smallestScreenSize aren't recognized, you'll have to compile aganist Android 3.2 or higher. Check out this migration blog post for more information on getting off of 4.1.1 to a newer version (the same applies to moving to 6.0.0 as well).

这篇关于com.google.ads.AdView未能实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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