pedrovgs / Shot

Screenshot testing library for Android
Apache License 2.0
1.18k stars 115 forks source link

[6.1.0][Api 30] NoSuchMethodException android.view.ViewRootImpl WindowAttachment.generateAttachInfo #354

Closed vudzkostek closed 7 months ago

vudzkostek commented 7 months ago

Afer upgrading shot to version 6.1.0 we get a lot of

Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: android.view.ViewRootImpl.<init> [class android.content.Context, class android.view.Display]
at com.facebook.testing.screenshot.WindowAttachment.generateAttachInfo(WindowAttachment.java:231)
at com.facebook.testing.screenshot.WindowAttachment.dispatchAttach(WindowAttachment.java:90)
at com.facebook.testing.screenshot.internal.ScreenshotImpl.storeBitmap(ScreenshotImpl.java:183)
at com.facebook.testing.screenshot.internal.ScreenshotImpl.access$000(ScreenshotImpl.java:50)
at com.facebook.testing.screenshot.internal.ScreenshotImpl$2.call(ScreenshotImpl.java:171)
at com.facebook.testing.screenshot.internal.ScreenshotImpl$2.call(ScreenshotImpl.java:168)
at com.facebook.testing.screenshot.internal.ScreenshotImpl$3.run(ScreenshotImpl.java:331)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NoSuchMethodException: android.view.ViewRootImpl.<init> [class android.content.Context, class android.view.Display]
at java.lang.Class.getConstructor0(Class.java:2332)
at java.lang.Class.getConstructor(Class.java:1728)
at com.facebook.testing.screenshot.WindowAttachment.generateAttachInfo(WindowAttachment.java:164)

We use emulator with api 30 and before 6.1.0 we did not have to enable non-sdk interfaces as in pedrovgs/Shot#using-shot-on-api-28. Althought, setting above does not help.

Versions

Shot: 6.1.0 Emulator: Pixel 4a Android Api 30

vudzkostek commented 7 months ago

pedrovgs/Shot#using-shot-on-api-28 did help, just couldn't execute from shell script 🤦