0

My app crashes when updated from previous version with Exception:

java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG

It runs fine when new version is fresh installed. The problem only occurs when it is updated from older version. It crashes on my second activity where I show image from drawables folder, the launcher activity works just fine.

This is how I show drawable image:

Image( painter = painterResource(id = myDataClass.iconResId), contentDescription = "" )

myDataClass is a data object, upon every app start I initialize iconResId propery with xml drawable resource id (since it can change on every app launch).

I have done upgrading properly: versionCode of new apk is greater than old apk versionName is also different string.

Might be worth noting, There are couple of extra drawables added in new version but none of old ones removed.

Tried debugging and checking if resource id is properly initialized in iconResId propery. It is being initialized properly.

2
  • 1
    stackoverflow.com/questions/72582702/… Check this issue Commented Sep 27, 2023 at 21:06
  • @KamilJeglikowski Yes I checked this before posting the question, reinstalling fixes the issue, but I need to upload my app to play store where users will upgrade from previous version, when this upgrade happens it crashes, otherwise if fresh installed it runs without any issues. Commented Sep 28, 2023 at 7:27

1 Answer 1

0

Check your file in drawable because if it is regular image with xml tags such as <shape/>, <layer-list/> etc - then you can't use it in Jetpack Compose. You should use .png/.jpg/.webp and other supported extensions or svg image imported through Vector Asset tool

Attach you image/file under iconResId variable and I can tell you more

4
  • Am not using <shape> or <layer-list> also app runs fine when it is fresh installed. Crashes only when upgraded from previous version. This is my iconResId and this is how I update resource ids on start of app. Commented Sep 28, 2023 at 7:24
  • try to change -1 in lines 37-38 to default image or 0. Something like companyIconResIds.getResourceId(index, 0) or companyIconResIds.getResourceId(index, R.drawable.default_company_icon) Commented Sep 28, 2023 at 7:31
  • I tried, it doesn't work. I think I found the root cause with this, even if am providing default as 0 or a default drawable, my DB isn't updating with it. It stays -1. I am passing updated Entity model to DAO's @Update method still don't know why it is not updating Commented Sep 28, 2023 at 9:14
  • I got it! App is crashing because the resource id is still of previous version (not getting updated because it taking id as 0 by default) Thanks for the help Commented Sep 28, 2023 at 9:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.