在Android中整合Admob的错误 [英] Error in integrating Admob in Android

查看:118
本文介绍了在Android中整合Admob的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完整的应用程序,我想加入AdMob的。

I have a completed app and I tried adding admob.

我得到了发布者ID,我已经在清单文件中添加它。当我在设备上运行,应用程序能正常工作在所有其他活动。然而,当我移动到了AdMob的广告被放置在活动中,我的应用程序崩溃,并且在logcat中会显示如下错误:

I got the publisher id and I have added it in manifest file. When I run in the device, the app works fine in all other activities. However, when I move to the activity where the admob ad has been placed, my app crashes, and in logcat it shows the following error:

都在logcat中显示的主要错误有三种:

The major errors shown in the logcat are as follows:

04-06 20:22:30.627:ERROR / AndroidRuntime(2339):   java.lang.RuntimeException的:无法启动的活动   ComponentInfo {com.mnn.image0114 / com.menteon.speedimage0114.ResultPage}:   android.view.InflateException:二进制XML文件中的行#8:错误   充气类com.admob.ads.AdView

04-06 20:22:30.627: ERROR/AndroidRuntime(2339): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mnn.image0114/com.menteon.speedimage0114.ResultPage}: android.view.InflateException: Binary XML file line #8: Error inflating class com.admob.ads.AdView

04-06 20:22:30.627:ERROR / AndroidRuntime(2339):产生的原因:   android.view.InflateException:二进制XML文件中的行#8:错误   充气类com.admob.ads.AdView

04-06 20:22:30.627: ERROR/AndroidRuntime(2339): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.admob.ads.AdView

04-06 20:22:30.627:ERROR / AndroidRuntime(2339):产生的原因:   抛出java.lang.ClassNotFoundException:com.admob.ads.AdView装载机   dalvik.system.PathClassLoader@44ccc270

04-06 20:22:30.627: ERROR/AndroidRuntime(2339): Caused by: java.lang.ClassNotFoundException: com.admob.ads.AdView in loader dalvik.system.PathClassLoader@44ccc270

如何解决这个问题?请帮我。

How to fix this error? Please help me.

推荐答案

如果您使用的是最新的AdMob罐子,你需要使用 com.google.ads.AdView 。这当然是在SDK 4.04的情况。

If you're using a recent AdMob jar, you need to be using com.google.ads.AdView. This is certainly the case in Sdk 4.04.

说了这么多,我没有直接把我的AdViews到XML,但使用了下列code把我的XML内的LinearLayout内的广告 -

Having said that, I didn't put my AdViews directly into the XML, but used the following code to place the ads inside a LinearLayout within my XML -

adView = new AdView(this, AdSize.BANNER, MY_ID);
LinearLayout layout = (LinearLayout) findViewById(R.id.adMob);
layout.addView(adView);
AdRequest adRequest = new AdRequest();
adRequest.setTesting(GlobalData.DebugBuild);
adView.loadAd(adRequest);

这篇关于在Android中整合Admob的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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