我在市场上有一个使用admob的应用程序,现在我想更新我的应用程序。当我测试这个新版本时,我得到了一个由admob引起的致命异常。
04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: android.view.InflateException: Binary XML file line #51: Error inflating class com.google.ads.AdView
04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
以下是第#51行的xml文件:
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/bottom_border"
android:layout_toLeftOf="@id/right_border"
ads:adSize="BANNER"
ads:adUnitId="my id"
ads:loadAdOnCreate="true" />
我没有对发布的原始应用进行任何重大更改。我只添加了一个启动画面和一些语言字符串文件,并将版本更改为1.2,已发布的应用程序是版本1.1。我想知道为什么这个应用程序将不再运行。
我再次尝试过,这是日志:
04-11 12:13:21.474: D/AndroidRuntime(282): Shutting down VM
04-11 12:13:21.474: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-11 12:13:21.644: E/AndroidRuntime(282): FATAL EXCEPTION: main
04-11 12:13:21.644: E/AndroidRuntime(282): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kmbdev.purrkitty/com.kmbdev.purrkitty.Cat1}: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.os.Looper.loop(Looper.java:123)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-11 12:13:21.644: E/AndroidRuntime(282): at dalvik.system.NativeStart.main(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.Activity.setContentView(Activity.java:1647)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.kmbdev.purrkitty.Cat1.onCreate(Cat1.java:25)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-11 12:13:21.644: E/AndroidRuntime(282): ... 11 more
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
04-11 12:13:21.644: E/AndroidRuntime(282): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-11 12:13:21.644: E/AndroidRuntime(282): ... 20 more
答案 0 :(得分:4)
我遇到了同样的问题,浪费了3个多小时来解决这个问题。最后,我找到了让它发挥作用的方法。
答案 1 :(得分:0)
你确定清单上有所有标签吗? (那是赞美之徒)。同样在XML中,你需要为xmlns添加一个addl标签吗?你有没说明呢?
答案 2 :(得分:0)
清理项目,如果尚未在Eclipse中激活自动构建,请进行手动构建。它会起作用。
答案 3 :(得分:0)
要解决这个问题,您只需要以两种方式链接sdk .jar文件。首先,将它添加到libs文件夹(如果你没有,创建它),然后右键单击.jar文件,转到Build Path-&gt; Add to Build Path ...三天得出这个结论。
答案 4 :(得分:0)
我通过将jar文件保存的文件夹从/lib
重命名为/libs
来修复它。