Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources$NotFoundException on tests with AlertDialog on latest compileSdk version #1025

Closed
jmartinesp opened this issue Jul 27, 2023 · 12 comments
Labels
bug Something isn't working
Milestone

Comments

@jmartinesp
Copy link

jmartinesp commented Jul 27, 2023

Description
Our tests with AlertDialog compose components are failing with stacktraces like this after settings both compileSdk and targetSdk to 34.

io.element.android.tests.uitests.ScreenshotTest > preview_tests[io.element.android.services.apperror.impl_null_DefaultGroup_AppErrorViewLightPreview_0_null,NEXUS_5,1.0,en] FAILED
    android.content.res.Resources$NotFoundException: Could not find dimen resource matching value 0x105024F (resolved name: resize_shadow_size) in current configuration.
        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.getDimensionPixelSize(Resources_Delegate.java:670)
        at app//android.content.res.Resources.getDimensionPixelSize(Resources.java:828)
        at app//com.android.internal.policy.DecorView.<init>(DecorView.java:320)
        at app//com.android.internal.policy.PhoneWindow.generateDecor(PhoneWindow.java:2385)
        at app//com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2727)
        at app//com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2144)
        at app//androidx.compose.ui.window.DialogWrapper.<init>(AndroidDialog.android.kt:352)
        at app//androidx.compose.ui.window.AndroidDialog_androidKt.Dialog(AndroidDialog.android.kt:163)
        at app//androidx.compose.material3.AndroidAlertDialog_androidKt.AlertDialog(AndroidAlertDialog.android.kt:151)
        at app//io.element.android.libraries.designsystem.components.dialogs.ErrorDialogKt.ErrorDialog-10sF2-8(ErrorDialog.kt:48)

Steps to Reproduce
Record screenshots of composables with AlertDialogs when using compileSdk and targetSdk set to 34.

Expected behavior
The screenshots should be recorded.

Additional information:

  • Paparazzi Version: 1.3.1
  • OS: MacOS
  • Compile SDK: 34
  • Gradle Version: 8.2.1
  • Android Gradle Plugin Version: 8.0.2
@jmartinesp jmartinesp added the bug Something isn't working label Jul 27, 2023
@jmartinesp jmartinesp changed the title Resources$NotFoundException on tests with AlertDialog on latest material3 compose alpha Resources$NotFoundException on tests with AlertDialog on latest compileSdk version Jul 27, 2023
@gabrielittner
Copy link
Contributor

gabrielittner commented Jul 27, 2023

We have this as a workaround:

Paparazzi(
  environment = detectEnvironment().run {
    copy(compileSdkVersion = 33, platformDir = platformDir.replace("34", "33"))
  },
)

That allows us to use compile and target sdk 34 while keeping Paparazzi on 33 until it supports the newer platform version. I assume it needs a layoutlib update

@ZacSweers
Copy link
Contributor

Note the above solution can require more work if your CI uses ephemeral nodes. You will need to ensure that SDK 33 is also actually installed

@alashow
Copy link

alashow commented Aug 22, 2023

Note the above solution can require more work if your CI uses ephemeral nodes. You will need to ensure that SDK 33 is also actually installed

Can confirm. I couldn't use sdkmanager (sdkmanager --install "platforms;android-33") in our CI, so to fix this I added empty module having compileSdk = 33 (while everything else is compileSdk = 34), which made AGP to install both 33 & 34 in build time.

Details
// dummy empty module with only build.gradle.kts (ex project/libs/compileSdk33-require/build.gradle.kts)
plugins {
   alias(libs.plugins.android.library)
}

android {
   namespace = "common.compilesdk33_require"
   compileSdk = 33

   defaultConfig {
       minSdk = 24
   }
}

// settings.gradle
include (":libs:compileSdk33-require") 

Then just add ./gradlew :libs:compileSdk33-require:build step to CI at beginning or before running tests (or just add implementation(project(':libs:compileSdk33-require')))

@dniHze
Copy link
Contributor

dniHze commented Aug 23, 2023

It looks like AS Hedgehog handles previews properly, whilst Giraffe Patch 1 is failing to render previews for such composables. I guess this would stick for a while until the next patch for Giraffe with SDK 34 support or Hedgehog is released.

@ZacSweers
Copy link
Contributor

Wait giraffe breaks compose previews on sdk 34?

@dniHze
Copy link
Contributor

dniHze commented Aug 23, 2023

Seems so, tested the same composable on Giraffe Patch 1 and Hedgehog Canary 16, and Giraffe renders 1x1px previews with compile SDK 34.

Upd: it renders regular composables, just fails on dialog and popups

@peterdk
Copy link

peterdk commented Oct 29, 2023

I had the same issue, and got it working with the workaround of setting environment to 33.
However, now my tests randomly fail with Resources$NotFOundException while it succeedes when I run them for a 2nd time...
So I am not sure why.

Tried with 1.3.2-SNAPSHOT.

Also, Hedgehog indeed breaks previews in AndroidStudio of my AlertDialogs.

@pstambrecht
Copy link

Snapshot 1.3.2-SNAPSHOT doesn't work for us.
Is this fix targeting into 1.3.2?

@dniHze
Copy link
Contributor

dniHze commented Nov 1, 2023

Snapshot 1.3.2-SNAPSHOT doesn't work for us. Is this fix targeting into 1.3.2?

👋 @pstambrecht

The bug is strictly dependent on the layoutlib. Paparazzi only updates to the most recent stable layoutlib. Until a stable build of layoutlib from AS Hedgehog that properly supports SDK 34 is released, I doubt something can be done without working around layoutlib internals. It looks like 🦔 has reached RC2 so the first release might be soon-ish 🤞.

@jrodbx
Copy link
Collaborator

jrodbx commented Jan 22, 2024

Looks like this won't be possible until Iguana, tracked in #1220.

Compare Hedgehog to Iguana noting this commit, in particular:

Screenshot 2024-01-22 at 8 26 54 AM

@peterdk
Copy link

peterdk commented Mar 10, 2024

Somehow it works now for me again. I use Buildtools version 34.0.0, and compileSdk 34. With latest Android SDK updates from check for updates dialog in Android studio. (Paparazzi 1.3.3)

However, I do have targetted Android 33. But that failed for me as well for Dialogs before. So FYI,

@jrodbx
Copy link
Collaborator

jrodbx commented Mar 29, 2024

Closed by #1314

@jrodbx jrodbx closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants