'Jetpack Compose preview stopped working in Arctic Fox with Patch 1

With the first patch for AS Arctic Fox Jetpack Compose previews stopped working.

I'm getting this error for all previews - even older ones, which worked fine a while back:

android.content.res.Resources$NotFoundException: Could not resolve resource value: [some hex value]

Are here any quick fixes for this? Clearing caches and the usual stuff did not work.


EDIT:
Looks like the problem is not always present. Some preview started working, while other are still failing.

EDIT 2:
This is happening in dynamic feature modules, when there's a need for resources from the main module or painterResource() is being used (even is resource from the same module is to be displayed).



Solution 1:[1]

Same problem here with dynamic-modules project. Inspired by above answer, I've made another temporary workaround while waiting for Compose team to fix this.

import androidx.compose.ui.res.stringResource as originalStringResource

@Composable
@ReadOnlyComposable
fun stringResourceSafe(@StringRes id: Int): String =
    if (BuildConfig.DEBUG) {
        val resources = LocalContext.current.resources
        try {
            resources.getString(id)
        } catch (e: Resources.NotFoundException) {
            "missing res."
        }
    } else {
        originalStringResource(id)
    }

Solution 2:[2]

As a temporary hack workaround I did this to get past the error and preview the UI elements.

//import androidx.compose.ui.res.stringResource

fun stringResource(id: Int): String {
    when (id) {
        R.string.res_id -> return "Foo"
        ...
    }
    return "missing res_id"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Damiancioo
Solution 2 Ryan M