icerockdev / moko-resources

Resources access for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.11k stars 121 forks source link

can't read UIImage of dev.icerock.moko.resources.ImageResource issue #483

Closed harshakiran3 closed 1 year ago

harshakiran3 commented 1 year ago

Getting the following error and then the app crashes.

Uncaught Kotlin exception: kotlin.IllegalArgumentException: can't read UIImage of dev.icerock.moko.resources.ImageResource@4bc1b080

Alex009 commented 1 year ago

this mean that this method

https://github.com/icerockdev/moko-resources/blob/15fadd5ff058a967b0980daaebc48bb76e6cf465/resources/src/iosMain/kotlin/dev/icerock/moko/resources/ImageResource.kt#L14

return null.

https://developer.apple.com/documentation/uikit/uiimage/1624154-imagenamed

as described in apple docs - nil is about no image found. what image you try to use? maybe file corrupted someway?

harshakiran3 commented 1 year ago

I was using Icon(painter = painterResource(MR.images.icon_bottomnav_home),contentDescription = screen.title) in a Compose file inside Shared module. It is running fine in Android but when I run on xcode, it crashes giving the error as Uncaught Kotlin exception: kotlin.IllegalArgumentException: can't read UIImage of dev.icerock.moko.resources.ImageResource@4bc1b080 Here MR.images.icon_bottomnav_home is a svg file

Alex009 commented 1 year ago

can you attach this svg file? and on what iOS version you try to run?

Alex009 commented 1 year ago

also check please release 0.22.2

msasikanth commented 1 year ago

Hi, I was having the same issue and it seems to resolved with 0.22.2 version

Alex009 commented 1 year ago

can you create reproducer from this template? https://github.com/icerockdev/moko-compose-multiplatform-ios-android-template

msasikanth commented 1 year ago

Umm, I mentioned it's resolved in the latest version 😅. I have it in this project https://github.com/msasikanth/reader

Alex009 commented 1 year ago

oh, sorry, i read incorrectly your previous message. cool that resolved! @harshakiran3 for your case issue resolved too, or not?

harshakiran3 commented 1 year ago

Hey @Alex009 The issue got resolved when I did invalidate cache and restart on Android studio and then clean build folder in XCode.

Alex009 commented 1 year ago

so i think we can close this issue