Question

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...

Was it helpful?

OTHER TIPS

I've found out the problem after looking at the cause.

Basically I was inflating a view in a AsyncTask but was doing that on the doInBackground() method, which apparently works on most devices, but not all of them.

I moved the inflate part to the onPostExecute() and it fixed the problem.

To fix the error:

In Manifest:

<application
        android:largeHeap="true"

In .xml file, you must remove the below code:

android:src="@drawable..
android:background="@drawable...

Because the error is out of memory error. It is good for me

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top