Org.xmlpull.v1.XmlPullParserException for "invalid label bitmap"

Okay, this is weird.

I got this error for one of my activities, it is strange that a bitmap is being used in every activity! I don't even know how to reproduce the exception, it works great for me (and others, I think).

This is the whole stack:

java.lang.RuntimeException: Unable to start activity ComponentInfo{it.enrichman.bolloauto/it.enrichman.bolloauto.activities.ArchivioActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1872)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4385)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class android.widget.ListView
at android.view.LayoutInflater.createView(LayoutInflater.java:518)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
at android.app.Activity.setContentView(Activity.java:1742)
at it.enrichman.bolloauto.activities.ArchivioActivity.onCreate(ArchivioActivity.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.view.LayoutInflater.createView(LayoutInflater.java:505)
... 22 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/backrepeat.xml from color state list resource ID #0x7f020075
at android.content.res.Resources.loadColorStateList(Resources.java:1855)
at android.content.res.TypedArray.getColor(TypedArray.java:319)
at android.widget.AbsListView.<init>(AbsListView.java:632)
at android.widget.ListView.<init>(ListView.java:164)
at android.widget.ListView.<init>(ListView.java:160)
... 25 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag bitmap
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:146)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:129)
at android.content.res.Resources.loadColorStateList(Resources.java:1852)
... 29 more

      

A "missing" resource is one (inside an accessible folder):

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/bg"
        android:tileMode="repeat" />

      

The "bg" drawable is inside drawable-hdpi (maybe this is the problem?), but as I said, it is used as a background in every action!

The error is thrown during layout customization:

setContentView(R.layout.archivio);

      

Xml layout:

<?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">

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="BLABLABLA"
            android:id="@+id/archivioTextView" android:layout_gravity="center_horizontal"
            android:gravity="center_horizontal" android:textIsSelectable="false" android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp" android:layout_marginRight="30dp" android:layout_marginLeft="30dp"/>
    <ListView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/listaVeicoli" android:layout_gravity="center" android:drawSelectorOnTop="false"/>
</LinearLayout>

      

(Some of the unhelpful statements are from the IntelliJ designer!)

I've looked for similar problems, but I don't have a "weird" id like @ + id / list or other problems other users have been using.

Any help on this? What am I missing? Thanks to

+3


source to share


3 answers


In the end I found a FULL solution. I tried with another emulator and I only ran into this crash with API 10 (2.3.3) or less. Looking around xmls and trying to do different things (also copying bg drawable all over the place or changing id to my list) I found this weird stuff in my custom theme:

<item name="android:windowBackground">@drawable/backrepeat</item>
<item name="android:colorBackground">@drawable/backrepeat</item>

      

This doesn't seem to be a problem for the newer Android version, but for the older version, yes.



Just remove the definition of colorBackground (maybe it should only be a color) and that's it!

I hope this helps someone else!

+6


source


Create a drawable folder inside the res folder . Try to keep bg inside "res / drawable /" .



Hope this helps you.

0


source


Put your selector in a folder res/drawable

and also specify Listview

id as android:id="@+android:id/list"

.

I hope this helps you.

Thank.

0


source







All Articles