标签的 Android InflateException
我有一个应用程序可以在我们测试过的大多数设备上运行,但在少数 20 个测试版用户中,其中 2 个遇到了一个非常奇怪的错误:
10-17 08:56:56.840 24805 24846 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class <unknown>
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:513)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at com.nzn.baixaki.AppsActivity$LoadCategoriesTask.doInBackground(AppsActivity.java:71)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at com.nzn.baixaki.AppsActivity$LoadCategoriesTask.doInBackground(AppsActivity.java:1)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:185)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: ... 4 more
10-17 08:56:56.840 24805 24846 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.widget.ListView.<init>(ListView.java:153)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:500)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: ... 14 more
这是 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- LINHA AZUL // -->
<LinearLayout
android:background="@drawable/bg_filters"
android:id="@+id/category_header"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<!-- LINHA DE CIMA // -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:paddingRight="10dip"
android:paddingLeft="10dip"
android:paddingTop="10dip">
<!-- LABEL 'CATEGORIA' -->
<TextView
android:gravity="center_vertical"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:textColor="@color/bxkBlue"
android:text="@string/category_title_call"
android:textSize="14dip"
android:layout_marginRight="5dip">
</TextView>
<!-- NOME DA CATEGORIA -->
<TextView
android:gravity="center_vertical"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:textColor="@color/bxkBlue"
android:text="Nome da categoria"
android:textSize="14dip"
android:textStyle="bold"
android:id="@+id/category_name">
</TextView>
</LinearLayout>
<View
android:layout_height="1dip"
android:layout_width="fill_parent"
android:background="#e5e5e5"/>
</LinearLayout>
<ListView
android:listSelector="@drawable/bg_list_selector"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/apps_list_view"></ListView>
</LinearLayout>
XML 上的第 52 行是 ListView
在底部。可能发生什么情况?
我真的不知道如何修复这个错误。
编辑:
阅读链接后,我仍然不知道,但是这个堆栈跟踪可能会有所帮助:
10-17 09:28:48.919 25897 25983 W System.err: Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
10-17 09:28:48.929 25897 25983 W System.err: at android.os.Handler.<init>(Handler.java:121)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector.<init>(GestureDetector.java:370)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector.<init>(GestureDetector.java:347)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector.<init>(GestureDetector.java:331)
10-17 09:28:48.929 25897 25983 W System.err: at android.widget.AbsListView.initAbsListView(AbsListView.java:585)
10-17 09:28:48.929 25897 25983 W System.err: at android.widget.AbsListView.<init>(AbsListView.java:544)
10-17 09:28:48.929 25897 25983 W System.err: at android.widget.ListView.<init>(ListView.java:157)
10-17 09:28:48.929 25897 25983 W System.err: ... 18 more
困扰我的是几乎所有代码都是“内部”而不是我的......
I have an app that works on most devices we've tested, but in the few 20 beta users 2 of them get a very weird error:
10-17 08:56:56.840 24805 24846 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class <unknown>
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:513)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at com.nzn.baixaki.AppsActivity$LoadCategoriesTask.doInBackground(AppsActivity.java:71)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at com.nzn.baixaki.AppsActivity$LoadCategoriesTask.doInBackground(AppsActivity.java:1)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:185)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: ... 4 more
10-17 08:56:56.840 24805 24846 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.widget.ListView.<init>(ListView.java:153)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at java.lang.reflect.Constructor.constructNative(Native Method)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:500)
10-17 08:56:56.840 24805 24846 E AndroidRuntime: ... 14 more
And here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- LINHA AZUL // -->
<LinearLayout
android:background="@drawable/bg_filters"
android:id="@+id/category_header"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">
<!-- LINHA DE CIMA // -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dip"
android:paddingRight="10dip"
android:paddingLeft="10dip"
android:paddingTop="10dip">
<!-- LABEL 'CATEGORIA' -->
<TextView
android:gravity="center_vertical"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:textColor="@color/bxkBlue"
android:text="@string/category_title_call"
android:textSize="14dip"
android:layout_marginRight="5dip">
</TextView>
<!-- NOME DA CATEGORIA -->
<TextView
android:gravity="center_vertical"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:textColor="@color/bxkBlue"
android:text="Nome da categoria"
android:textSize="14dip"
android:textStyle="bold"
android:id="@+id/category_name">
</TextView>
</LinearLayout>
<View
android:layout_height="1dip"
android:layout_width="fill_parent"
android:background="#e5e5e5"/>
</LinearLayout>
<ListView
android:listSelector="@drawable/bg_list_selector"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/apps_list_view"></ListView>
</LinearLayout>
Line 52 on the XML is the ListView
at the bottom. What could be happening?
I really have no idea of how to fix this error.
EDIT:
After reading a link, I've still got no idea, but this stacktrace might help:
10-17 09:28:48.919 25897 25983 W System.err: Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
10-17 09:28:48.929 25897 25983 W System.err: at android.os.Handler.<init>(Handler.java:121)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector$GestureHandler.<init>(GestureDetector.java:250)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector.<init>(GestureDetector.java:370)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector.<init>(GestureDetector.java:347)
10-17 09:28:48.929 25897 25983 W System.err: at android.view.GestureDetector.<init>(GestureDetector.java:331)
10-17 09:28:48.929 25897 25983 W System.err: at android.widget.AbsListView.initAbsListView(AbsListView.java:585)
10-17 09:28:48.929 25897 25983 W System.err: at android.widget.AbsListView.<init>(AbsListView.java:544)
10-17 09:28:48.929 25897 25983 W System.err: at android.widget.ListView.<init>(ListView.java:157)
10-17 09:28:48.929 25897 25983 W System.err: ... 18 more
What is bugging me is that pretty much all the code is "internal" and not mine...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
看看这个:膨胀 xml - android 时的 InvokingTargetException
Check this out: InvocationTargetException on inflating an xml - android