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

MotionLayout inflation fails with NullPointerException #1850

Open
BernadetteTh opened this issue Feb 26, 2025 · 0 comments
Open

MotionLayout inflation fails with NullPointerException #1850

BernadetteTh opened this issue Feb 26, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@BernadetteTh
Copy link

Description
androidx MotionLayout does not inflate when running a test, crashes instead.
Crashlog below:

LoadingScreenTest > testLoadingScreen FAILED
    android.view.InflateException: Binary XML file line #12: Error inflating class androidx.constraintlayout.motion.widget.MotionLayout

        Caused by:
        java.lang.reflect.InvocationTargetException
            at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
            at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
            at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
            at android.view.LayoutInflater.createView(LayoutInflater.java:866)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1018)
            at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:321)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:973)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:667)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
            at android.view.BridgeInflater.inflate(BridgeInflater.java:395)
            at app.cash.paparazzi.PaparazziSdk.inflate(PaparazziSdk.kt:167)
            at app.cash.paparazzi.Paparazzi.inflate(Paparazzi.kt:98)
            at com.defaultui.snapshot.LoadingScreenTest.setUp(LoadingScreenTest.kt:17)

            Caused by:
            java.lang.NullPointerException: Cannot read field "type" because the return value of "android.content.res.TypedArray.peekValue(int)" is null
                at androidx.constraintlayout.motion.widget.KeyAttributes$Loader.read(KeyAttributes.java:402)
                at androidx.constraintlayout.motion.widget.KeyAttributes.load(KeyAttributes.java:73)
                at androidx.constraintlayout.motion.widget.KeyFrames.<init>(KeyFrames.java:115)
                at androidx.constraintlayout.motion.widget.MotionScene.load(MotionScene.java:1275)
                at androidx.constraintlayout.motion.widget.MotionScene.<init>(MotionScene.java:1190)
                at androidx.constraintlayout.motion.widget.MotionLayout.init(MotionLayout.java:4019)
                at androidx.constraintlayout.motion.widget.MotionLayout.<init>(MotionLayout.java:1159)
                ... 15 more

1 test completed, 1 failed

> Task :defaultui:testDebugUnitTest FAILED

FAILURE: Build failed with an exception.

Only seems to happen with androidx.constraintlayout:constraintlayout:2.2.0
When I downgrade to version 2.1.4, the layout inflates as expected. ConstraintLayout itself always inflates fine.

Steps to Reproduce
Try to do a test run that inflates any androidx.constraintlayout.motion.widget.MotionLayout layout, using andoridx constraintlayout version 2.2.0

Expected behavior
NullPointerException should not happen, layout should inflate

Additional information:

  • Paparazzi Version: 1.3.5
  • OS: Mac Sonoma 14.6.1
  • Compile SDK: 35
  • Gradle Version: 8.9
  • Android Gradle Plugin Version: 8.7.3
@BernadetteTh BernadetteTh added the bug Something isn't working label Feb 26, 2025
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

1 participant