-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Description
With Robolectric 4.11 and SDK level 30, a NoClassDefFoundError is encountered when calling PixelCopy.request. This error does not occur when using SDK level 34 or when capturing screenshots via View.draw as shown in this pull request. I would prefer to use Robolectric's native mechanisms for screenshot capture in the Roborazzi library whenever possible.
Steps to Reproduce
- Configure a test to use Robolectric 4.11 with SDK level 30 or lower.
- Invoke PixelCopy.request.
- Observe that the NoClassDefFoundError for android/view/PixelCopy$Request occurs.
Example failure:
android/view/PixelCopy$Request
java.lang.NoClassDefFoundError: android/view/PixelCopy$Request
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
at java.base/java.lang.Class.getDeclaredMethod(Class.java:2673)
at org.robolectric.internal.bytecode.ShadowWrangler.findShadowMethodDeclaredOnClass(ShadowWrangler.java:338)
at org.robolectric.internal.bytecode.ShadowWrangler.findShadowMethod(ShadowWrangler.java:307)
at org.robolectric.internal.bytecode.ShadowWrangler.pickShadowMethod(ShadowWrangler.java:284)
at org.robolectric.internal.bytecode.ShadowWrangler.lambda$findShadowMethodHandle$0(ShadowWrangler.java:222)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
at org.robolectric.internal.bytecode.ShadowWrangler.findShadowMethodHandle(ShadowWrangler.java:216)
at org.robolectric.internal.bytecode.RobolectricInternals.findShadowMethodHandle(RobolectricInternals.java:36)
at org.robolectric.internal.bytecode.InvokeDynamicSupport.bindCallSite(InvokeDynamicSupport.java:161)
at org.robolectric.internal.bytecode.InvokeDynamicSupport.lambda$bootstrapStatic$2(InvokeDynamicSupport.java:104)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
at org.robolectric.internal.bytecode.InvokeDynamicSupport.bootstrapStatic(InvokeDynamicSupport.java:98)
at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:109)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:315)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:281)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:271)
at android.view.PixelCopy.request(PixelCopy.java)
at com.github.takahirom.roborazzi.ViewScreenshotKt.generateBitmapFromPixelCopy(ViewScreenshot.kt:201)
at com.github.takahirom.roborazzi.ViewScreenshotKt.generateBitmapFromPixelCopy(ViewScreenshot.kt:184)
at com.github.takahirom.roborazzi.ViewScreenshotKt.generateBitmap(ViewScreenshot.kt:122)
Robolectric & Android Version
Robolectric version: 4.11
Android SDK tested: 30
Link to a public git repo demonstrating the problem:
https://github.com/takahirom/roborazzi/actions/runs/6686917489/job/18166895974
https://github.com/takahirom/roborazzi/blob/14a62c6c069422089b71f25a0f7f01310966b6f8/include-build/roborazzi-core/src/androidMain/kotlin/com/github/takahirom/roborazzi/ViewScreenshot.kt#L200-L206
Metadata
Metadata
Assignees
Labels
No labels