question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Exception in HostObject::get for prop 'NativeUnimoduleProxy': java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Any, js engine: hermes

See original GitHub issue

Summary

I just migrated to the expo from react-native-unimodules. this error is happening only for android when I open app on android.

I also did a patch to expo-file-system may be it is due to that patch https://github.com/expo/expo/issues/15632#issuecomment-1000943427

here is the full error log

Error: Exception in HostObject::get for prop 'NativeUnimoduleProxy': java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Any, js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

if I uninstall the app and reinstall the app then this error is gone.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

No response

Environment

Expo CLI 5.0.3 environment info: System: OS: macOS 12.1 Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 6.14.10 - ~/.nvm/versions/node/v14.15.4/bin/npm Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: API Levels: 22, 23, 25, 26, 27, 28, 29, 30, 31 Build Tools: 26.0.0, 26.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0 System Images: android-24 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 13.2/13C90 - /usr/bin/xcodebuild npmPackages: babel-preset-expo: ^9.0.2 => 9.0.2 expo: ^44.0.4 => 44.0.4 react: ^17.0.2 => 17.0.2 react-native: ^0.66.4 => 0.66.4 npmGlobalPackages: eas-cli: 0.41.1 expo-cli: 5.0.3 Expo Workflow: bare

Reproducible demo

I think it will be reproduced when you will use the same version of RN and expo which I am using. you have to update the existing app in mobile for reproducing instead of installing fresh APK

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
photorouletteadmincommented, Jan 19, 2022

I think it might be the same issue as this one: https://github.com/expo/expo/issues/15924

0reactions
photorouletteadmincommented, Feb 15, 2022

I patched in using patch-package and this patch (expo-localization+12.0.1.patch):

diff --git a/node_modules/expo-localization/android/src/main/java/expo/modules/localization/LocalizationModule.kt b/node_modules/expo-localization/android/src/main/java/expo/modules/localization/LocalizationModule.kt
index d93e0d1..edc70f7 100644
--- a/node_modules/expo-localization/android/src/main/java/expo/modules/localization/LocalizationModule.kt
+++ b/node_modules/expo-localization/android/src/main/java/expo/modules/localization/LocalizationModule.kt
@@ -24,11 +24,11 @@ class LocalizationModule(context: Context) : ExportedModule(context) {
 
   override fun getName() = "ExpoLocalization"
 
-  override fun getConstants(): Map<String, Any> {
-    val constants = HashMap<String, Any>()
+  override fun getConstants(): Map<String, Any?> {
+    val constants = HashMap<String, Any?>()
     val bundle = bundledConstants
     for (key in bundle.keySet()) {
-      constants[key] = bundle[key] as Any
+      constants[key] = bundle[key] as Any?
     }
     return constants
   }
Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes and gives this error java.lang.NullPointerException
App crashes and gives this error java.lang.NullPointerException: null cannot be cast to non-null type android.content.Context.
Read more >
JVM / IR: "NullPointerException: null cannot be cast to non ...
BackendException : Backend Internal error: Exception during Experimental parallel IR backend File being compiled: <redacted> The root cause java.lang.
Read more >
Kotlin NullPointerException: Parameter specified as non-null ...
In this quick tutorial, we're going to see what happens when we store a null value into a non-null data type in Kotlin....
Read more >
Casting null to a generic non-null type discrepancy : r/Kotlin
Basically, when Idirectly cast a null value to a non-null type, it will throw java.lang.NullPointerException: null cannot be cast to non-null ...
Read more >
kotlin java.lang.NullPointerException: null cannot be cast to ...
Coding example for the question kotlin java.lang.NullPointerException: null cannot be cast to non-null type androidx.navigation.fragment.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found