cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.32k stars 216 forks source link

Resources$NotFoundException when accessing app module resource from dynamic feature module #1060

Open juckrit opened 1 year ago

juckrit commented 1 year ago

Description I have composable function in dynamicFeature Module that show Image that image file is in app module when I run "gradle recordPaparazziDebug" the test fail with Resources$NotFoundException

Steps to Reproduce

  1. clone this sample project https://github.com/juckrit/Poc_Paparazzi
  2. run gradle task "recordPaparazziDebug"

Expected behavior The test should pass

Additional information:

Screenshots

Screenshot 2566-08-25 at 20 42 50
jacobtabak commented 1 year ago

EDIT: Solved by updating to the latest version of Paparazzi and plugin.

I have a similar issue.

I'm not using a dynamic feature module, but the resources being referenced are in a different module.

The problem manifested after upgrading to Gradle 8.3 and AGP 8.1.1.

android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F06027E.
    at app//android.content.res.Resources_Delegate.throwException(Resources_Delegate.java:1161)
    at app//android.content.res.Resources_Delegate.throwException(Resources_Delegate.java:1137)
    at app//android.content.res.Resources_Delegate.throwException(Resources_Delegate.java:1141)
    at app//android.content.res.Resources_Delegate.getColorStateList(Resources_Delegate.java:264)
    at app//android.content.res.Resources_Delegate.getColor(Resources_Delegate.java:242)
    at app//android.content.res.Resources.getColor(Resources.java:1065)
    at app//androidx.compose.ui.res.ColorResourceHelper.getColor-WaAFU9c(ColorResources.android.kt:51)
    at app//androidx.compose.ui.res.ColorResources_androidKt.colorResource(ColorResources.android.kt:40)
    at app//com.seatgeek.android.compose.theme.SeatGeekTheme$colorsCache$1.invoke(SeatGeekTheme.kt:64)
    at app//com.seatgeek.android.compose.theme.SeatGeekTheme$colorsCache$1.invoke(SeatGeekTheme.kt:61)
    at app//com.seatgeek.android.compose.extensions.ComposableCache.value(ComposableCache.kt:18)
    at app//com.seatgeek.android.compose.theme.SeatGeekTheme.getColors(SeatGeekTheme.kt:539)
    at app//com.seatgeek.android.design.abi.theme.DesignSystemThemeKt.DesignSystemTheme(DesignSystemTheme.kt:137)
    at app//com.seatgeek.android.compose.view.core.SgComposeEntrypointKt.ThemedContent(SgComposeEntrypoint.kt:59)
    at app//com.seatgeek.android.compose.view.core.SgComposeEntrypointKt.SgComposeEntrypoint(SgComposeEntrypoint.kt:45)
    at app//com.seatgeek.android.design.compose.preview.SgPreviewKt$SgPreview$1.invoke(SgPreview.kt:20)
    at app//com.seatgeek.android.design.compose.preview.SgPreviewKt$SgPreview$1.invoke(SgPreview.kt:19)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
    at app//androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at app//com.seatgeek.android.design.compose.preview.SgPreviewKt.SgPreview(SgPreview.kt:19)
    at app//com.seatgeek.testing.snapshot.paparazzi.PaparazzisKt$sgSnapshot$1.invoke(Paparazzis.kt:18)
    at app//com.seatgeek.testing.snapshot.paparazzi.PaparazzisKt$sgSnapshot$1.invoke(Paparazzis.kt:17)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
    at app//androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428)
    at app//androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
    at app//androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
    at app//androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at app//androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:194)
    at app//androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)
    at app//androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
    at app//androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at app//androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:156)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:155)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
    at app//androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:155)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
    at app//androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
    at app//androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
    at app//androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3373)
    at app//androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3363)
    at app//androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
    at app//androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source)
    at app//androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3363)
    at app//androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3298)
    at app//androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587)
    at app//androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:966)
    at app//androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
    at app//androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1099)
    at app//androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)
    at app//androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:181)
    at app//androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
    at app//androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)
    at app//androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
    at app//androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1174)
    at app//android.view.View.dispatchAttachedToWindow(View.java:21291)
    at app//android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3491)
    at app//android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
    at app//android.view.ViewGroup.addViewInner(ViewGroup.java:5291)
    at app//android.view.ViewGroup.addView(ViewGroup.java:5077)
    at app//android.view.ViewGroup.addView(ViewGroup.java:5017)
    at app//android.view.ViewGroup.addView(ViewGroup.java:4989)
    at app//app.cash.paparazzi.Paparazzi.takeSnapshots(Paparazzi.kt:303)
    at app//app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:200)
    at app//app.cash.paparazzi.Paparazzi.snapshot$default(Paparazzi.kt:199)
    at app//app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:195)
    at app//app.cash.paparazzi.Paparazzi.snapshot$default(Paparazzi.kt:191)
    at app//com.seatgeek.testing.snapshot.paparazzi.PaparazzisKt.sgSnapshot(Paparazzis.kt:17)
    at app//com.seatgeek.android.checkout.CheckoutSnapshotTestsKt.checkoutSnapshot(CheckoutSnapshotTests.kt:674)
    at app//com.seatgeek.android.checkout.CheckoutSnapshotTests.checkoutAcknowledgements(CheckoutSnapshotTests.kt:91)
jrodbx commented 1 year ago

@jacobtabak by latest version, do you mean the snapshot (since OP is referring to 1.3.1)?

jrodbx commented 1 year ago

@juckrit: if so to the above ^, would you mind trying the latest snapshot and verifying the problem is now fixed?

FergusK commented 1 year ago

Hi @jrodbx,

I'm facing a similar issue to @juckrit Have an example of it here https://github.com/FergusK/snapshot-test-module-poc with two modules

AGP: 8.1 Paparazzi plugin: 1.3.2-SNAPSHOT

juckrit commented 1 year ago

@juckrit: if so to the above ^, would you mind trying the latest snapshot and verifying the problem is now fixed?

I tried with paparazzi version 1.3.1. It's not working

juckrit commented 1 year ago

@juckrit: if so to the above ^, would you mind trying the latest snapshot and verifying the problem is now fixed?

Ok. I already update my project to use version "1.3.2-SNAPSHOT" but it's still not working

tiny0Xy9 commented 1 year ago

I'm also experiencing a similar problem. Here is the environment.

パパラッチ バージョン: 1.3.1 および 1.3.2-SNAPSHOT
OS:Mac OS 13.5
SDKのコンパイル: 33
グラドルバージョン: 8.0
Android Gradle プラグイン バージョン: 8.1.0

The module configuration is the same as below. https://github.com/android/nowinandroid/pull/101

🙏

douglasmarques commented 1 year ago

Facing the same issue, is there any workaround so far?

linean commented 12 months ago

Same issue on my end 😢 paparazzi: 1.3.1 agp: 8.0.2 gradle: 8.1.1

kevinzheng-ap commented 10 months ago

@jrodbx I can investigate this one this week if you have not planned to

jrodbx commented 10 months ago

@jrodbx I can investigate this one this week if you have not planned to

Please do. Thanks.

myakici commented 8 months ago

Any updates on fixing this bug. Thanks.

iArtuc commented 7 months ago

have the same problem any news on this?

MedetZhakupov commented 7 months ago

I see that issue has been going on for a while now. Can we proceed with the new release 1.3.4 @jrodbx?

kevinzheng-ap commented 5 months ago

The root cause of issue is that resources and assets artifacts are not published in application module, leading dynamic feature modules unable to consume them. After extensive investigation, it's evident that the proper resolution lies within AGP. A bug has been filed here, and I've been urging for its escalation. Hopefully, it will be addressed promptly, allowing us to integrate the new AGP into Paparazzi thereafter.

cc @jrodbx