android-jetpackcomposable

Android IllegalArgumentException when trying to use PNG in Jetpack Compose


I'm trying to go through the Jetpack Compose tutorial. I am at the step of including an image and I am using the image they provide.

Profile picture

I have saved it in the Resource Manager. I am calling it here:

    @Composable
    fun MessageCard(msg: Message) {
        Row() {
            Image(painterResource(R.drawable.profile_picture),
            "Profile picture"
            )

            Column() {
                Text(text = msg.author)
                Text(text = msg.body)
            }
        }
    }

but I am getting the error java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG. I have checked the header bytes of the image, and they are ‰PNG as they should be. Am I missing something rather obvious here?


Solution

  • Ok, as it turns out I guess that I copied and pasted it incorrectly. I went back and redid the process of importing it into the Resource Manager, and now it works.