1

我试图在我的 android 应用程序中显示一个 adview,但它显示了一个 InflateException。这会终止应用程序,我不能做任何事情。

这是我的日志猫-

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 
4

2 回答 2

1

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

于 2013-05-06T14:27:45.370 回答
-1

我出现了同样的错误,我通过几个简单的步骤解决了。

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

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

于 2014-10-17T05:42:51.470 回答