类com.google.ads.AdView(InflateException)出错时出错

时间:2013-05-06 14:22:10

标签: android admob adview inflate-exception

我正在尝试在我的Android应用程序中显示广告视图,但它显示了InflateException。这终止了应用程序,我什么也做不了。

这是我的logcat -

05-06 14:09:09.428: E/AndroidRuntime(928): FATAL EXCEPTION: main
05-06 14:09:09.428: E/AndroidRuntime(928): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kodspider.parkon/com.kodspider.parkon.HomeActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class com.google.ads.AdView
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.os.Looper.loop(Looper.java:137)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.ActivityThread.main(ActivityThread.java:5039)
05-06 14:09:09.428: E/AndroidRuntime(928):  at java.lang.reflect.Method.invokeNative(Native Method)
05-06 14:09:09.428: E/AndroidRuntime(928):  at java.lang.reflect.Method.invoke(Method.java:511)
05-06 14:09:09.428: E/AndroidRuntime(928):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-06 14:09:09.428: E/AndroidRuntime(928):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-06 14:09:09.428: E/AndroidRuntime(928):  at dalvik.system.NativeStart.main(Native Method)
05-06 14:09:09.428: E/AndroidRuntime(928): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class com.google.ads.AdView
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-06 14:09:09.428: E/AndroidRuntime(928):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.Activity.setContentView(Activity.java:1881)
05-06 14:09:09.428: E/AndroidRuntime(928):  at com.kodspider.parkon.HomeActivity.onCreate(HomeActivity.java:31)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.Activity.performCreate(Activity.java:5104)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-06 14:09:09.428: E/AndroidRuntime(928):  ... 11 more
05-06 14:09:09.428: E/AndroidRuntime(928): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.ads.AdView" on path: /system/framework/com.google.android.maps.jar:/data/app/com.kodspider.parkon-2.apk
05-06 14:09:09.428: E/AndroidRuntime(928):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-06 14:09:09.428: E/AndroidRuntime(928):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-06 14:09:09.428: E/AndroidRuntime(928):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.createView(LayoutInflater.java:552)
05-06 14:09:09.428: E/AndroidRuntime(928):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
05-06 14:09:09.428: E/AndroidRuntime(928):  ... 22 more 

2 个答案:

答案 0 :(得分:1)

您需要将admob jar放入项目的libs文件夹中。

答案 1 :(得分:-1)

同样的错误出现在我身上,我用几个简单的步骤解决了。

您需要从项目中删除appcombat依赖项。 要删除,请右键单击项目 - > android->删除应用实战,并确保已选择android 4.2.2

然后将google admob jar导入您的项目。