Annyce Davis

Davis Technology Consulting

  • Home
  • About Me
  • Blog
  • Courses
  • Newsletter

The Little Things: Confusing error messages

June 26, 2024 by Annyce Davis

This series is dedicated to the little things in programming that make you want to bang your head against the wall. Today’s post is about: confusing error messages.

The code

I added a navigation icon to an app bar using Jetpack Compose. Initially, the icon was a Material one. The code looked like this:

navigationIcon = {
    Icon(
        imageVector = Icons.Filled.ShoppingCart,
        contentDescription = null
    )
}

Everything worked perfectly. I had a nice little shopping cart icon next to the app title. Then, I wanted to use a custom icon with the Android Studio Image Asset tool. I created the icon and plugged it into the code.

navigationIcon = {
  Icon(
      imageVector = ImageVector.vectorResource(R.drawable.ic_logo),
      contentDescription = null
   )
}

However, this time, the Compose Preview wouldn’t render. 😔

The error message

org.xmlpull.v1.XmlPullParserException:  unterminated entity ref (position:TEXT ‰PNG   
IHDR...@6:155 in java.io.InputStreamReader@ 25a0b497)  at org.kxml2.io.KXmlParser.exception( Unknown Source) at org.kxml2.io.KXmlParser.error( Unknown Source) at 
org.kxml2.io.KXmlParser.pushEntity( Unknown Source)
...

My eyes jumped straight to the PNG in the error message. And down the rabbit hole I went.

  • Was the PNG corrupted?
  • Did it have too many colors?
  • Was the size too large?
  • And on and on…

Nothing worked. I restarted Android Studio, cleared the caches, still no dice.

Two days later

I stared at the code with a cup of coffee in my hands. And then I thought XmlPullParserException? This is a PNG. And so, I switched the imageVector property to a painter property.

navigationIcon = {
  Icon(
      painter = painterResource(R.drawable.ic_logo),
      contentDescription = null
   )
}

And yeah, it worked!

The error message was confusing and unhelpful. If it said, “This is not a vector image, it’s a PNG.” I would have spotted my error right away and moved on.

Just one of those little things. fin

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Reddit (Opens in new window) Reddit

Related

Filed Under: Android, Software Development Tagged With: Android, Jetpack Compose, The Little Things

Follow Me

  • Bluesky

Categories

  • Android (60)
  • Career (5)
  • Communication (4)
  • Flutter (1)
  • Git (4)
  • Gradle (4)
  • Grails (23)
  • iOS (1)
  • Java (8)
  • JavaScript (6)
  • Kotlin (17)
  • Life (5)
  • Public Speaking (26)
  • Revenue (2)
  • RxJava (1)
  • Software Development (13)
  • Twitter (3)
  • Uncategorized (11)
  • Video Course (5)

Follow Me

  • Bluesky

Copyright © 2025 · All Rights Reserved · Log in

 

Loading Comments...