Usage of PixelUtil causes crash on the app start
See original GitHub issueDescription
We got lots of following crash on our app at production:
Caused by java.lang.NullPointerException: Attempt to read from field 'float android.util.DisplayMetrics.density' on a null object reference
at android.util.TypedValue.applyDimension(TypedValue.java:391)
at com.facebook.react.uimanager.PixelUtil.toPixelFromDIP(PixelUtil.java:18)
at com.swmansion.rnscreens.ScreenStackFragment.<clinit>(ScreenStackFragment.java:64)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:548)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:390)
at androidx.fragment.app.FragmentStateManager.<init>(FragmentStateManager.java:74)
at androidx.fragment.app.FragmentManager.restoreSaveState(FragmentManager.java:2454)
at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:196)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:287)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:115)
at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)
It is caused by usage of PixeUtil to assign static variable at start.
My commit may fix this. Since I don’t know how to reproduce this on my test devices, I will test on production app and will open a pull request.
Package versions
- React: 16.9.0, 17.0.1
- React Native: 0.63.2, 0.64.2
- React Native Screens: 3.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Why do my apps keep crashing on Android, How to fix it
There can be multiple reasons why apps to freeze or crash, especially when you ... Android apps can build up large caches based...
Read more >Detect and diagnose crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >Why Do My Apps Keep Crashing on Android? - Avast
Do your Android apps keep crashing? Discover why and learn how to prevent Android apps crashing and freezing by following these methods.
Read more >How to Fix Crashing Apps on an iPhone or Android?
Fix App Crashes on your Apple iPhone or Android smartphone. Kill the App; Restart the Phone; Update the App; Official Support; Use Bugfender!...
Read more >Fix an Android device that's restarting or crashing
Try the following steps if your phone has any of these problems: Randomly reboots or restarts; Shuts down without restarting; Restarts constantly: Go...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@WoLewicki PR doesn’t affect the changing shadow hidden/shown setting. I believe we can merge the PR.
@WoLewicki I don’t know to reproduce the crash. The app just crashes on start before loading any screen. It happens on different android versions and different vendors randomly. I tested it on production because I don’t know to reproduce it and we no longer see the crash.
Our apps don’t use toolbar and I will check it later to confirm if it is still working.