错误充气类com.google.android.gms.ads.AdView机器人工作室 [英] Error inflating class com.google.android.gms.ads.AdView Android Studio

查看:447
本文介绍了错误充气类com.google.android.gms.ads.AdView机器人工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要疯了。

我想使用谷歌播放服务改变AdMob的。但是,我是卡在这个错误。

I'm trying to change admob using google play services. But i'm stuck on this error.

Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class com.google.android.gms.ads.AdView

我这样的:

<com.google.android.gms.ads.AdView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="5dp"
    android:id="@+id/adViewPers"/>

和这样的:

<meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
<activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

主要活动

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

...
private AdView adViewPers;

...

adViewPers = (AdView) findViewById(R.id.adViewPers);
adViewPers.setAdUnitId("xxxxxxx");
adViewPers.setAdSize(AdSize.SMART_BANNER);
AdRequest adRequest = new AdRequest.Builder().build();
adViewPers.loadAd(adRequest);

和依赖关系:

我在做什么错????

what i'm doing wrong????

推荐答案

更​​好的方法,包括谷歌播放服务是通过在项目结构对话框图书馆依赖 - 而不是添加为你做的jar文件,单击+按钮>库的依赖。谷歌游戏服务应该是在列表中。

The better way to include Google Play Services is via a Library dependency in the Project Structure dialog -- instead of adding the jar file as you have done, click the + button > Library dependency. Google Play Services should be in the list.

另外,如果你要添加的jar文件,它真的最好不要把它们放在build文件夹 - 如果你做一个干净的构建,可以得到消除。最好的地方是在你的模块根libs目录。

Also, if you're adding jar files, it's really best to not put them in the build folder -- that can get erased if you do a clean build. The best place is in a libs directory at your module root.

这篇关于错误充气类com.google.android.gms.ads.AdView机器人工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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