Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Crash on build from flavor on Android #471

Closed
RomanSytnyk opened this issue Oct 31, 2022 · 3 comments
Closed

Crash on build from flavor on Android #471

RomanSytnyk opened this issue Oct 31, 2022 · 3 comments

Comments

@RomanSytnyk
Copy link

RomanSytnyk commented Oct 31, 2022

reanct-native-mmkv version 2.5.1
react-native 0.70.4 (recently upgraded from 0.68.3)

Debug version of the app works fine with run-android works fine.

But when I build the app from flavor for Android, for example production version or even debug versob, the app crashes on startup with the following logs:

E/ReactNativeJS: Error: Failed to create a new MMKV instance, the native initializer function does not exist. Is the native MMKV library correctly installed? Make sure to disable any remote debugger (e.g. Chrome) to use JSI!, js engine: hermes
E/ReactNativeJS: TypeError: Cannot read property 'store' of undefined
    
    This error is located at:
        in n
        in RCTView
        in Unknown
        in RCTView
        in Unknown
        in b, js engine: hermes
E/ReactNativeJS: TypeError: Cannot read property 'store' of undefined
    
    This error is located at:
        in n
        in RCTView
        in Unknown
        in RCTView
        in Unknown
        in b, js engine: hermes
E/unknown:ReactNative: Exception in native call
    com.facebook.react.common.JavascriptException: Error: Failed to create a new MMKV instance, the native initializer function does not exist. Is the native MMKV library correctly installed? Make sure to disable any remote debugger (e.g. Chrome) to use JSI!, js engine: hermes, stack:
    u@48:1364
    anonymous@1585:105
    h@2:1585
    d@2:1028
    o@2:496
    anonymous@1584:189
    h@2:1585
    d@2:1028
    o@2:496
    anonymous@1570:318
    h@2:1585
    d@2:958
    o@2:496
    n@422:256
    yr@83:42093
    ql@83:90924
    Fa@83:81696
    Ua@83:81598
    La@83:81363
    Ea@83:78326
    ft@83:26123
    _a@83:75415
    li@83:89662
    anonymous@83:96412
    anonymous@367:646
    run@364:683
    runApplication@364:1797
    value@63:3556
    anonymous@63:673
    value@63:2503
    value@63:645
    
        at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
        at com.facebook.jni.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:236)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:923)
E/unknown:ReactNative: TypeError: Cannot read property 'store' of undefined
    
    This error is located at:
        in n
        in RCTView
        in Unknown
        in RCTView
        in Unknown
        in b, js engine: hermes, stack:
    n@422:262
    yr@83:42093
    ql@83:90924
    Fa@83:81696
    Ua@83:81598
    La@83:81363
    Ea@83:78326
    ft@83:26123
    _a@83:75415
    li@83:89662
    anonymous@83:96412
    anonymous@367:646
    run@364:683
    runApplication@364:1797
    value@63:3556
    anonymous@63:673
    value@63:2503
    value@63:645
E/unknown:ReactNative: Exception in native call
    com.facebook.react.common.JavascriptException: TypeError: Cannot read property 'store' of undefined
    
    This error is located at:
        in n
        in RCTView
        in Unknown
        in RCTView
        in Unknown
        in b, js engine: hermes, stack:
    n@422:262
    yr@83:42093
    ql@83:90924
    Fa@83:81696
    Ua@83:81598
    La@83:81363
    Ea@83:78326
    ft@83:26123
    _a@83:75415
    li@83:89662
    anonymous@83:96412
    anonymous@367:646
    run@364:683
    runApplication@364:1797
    value@63:3556
    anonymous@63:673
    value@63:2503
    value@63:645
    
        at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
        at com.facebook.jni.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:236)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
        at java.lang.Thread.run(Thread.java:923)
@mrousavy
Copy link
Owner

Huh, weird.

  1. Can you reproduce this in the example app?
  2. Does this happen on iOS as well?

@RomanSytnyk
Copy link
Author

RomanSytnyk commented Oct 31, 2022

UPD: iOS is working fine

Well, it looks like React Native issue.

I've tried to manually generate the bundle file, like it's described in this issue related to similar RN upgrade:
facebook/react-native#34606 (comment)

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
./gradlew clean app:assembleRelease --stacktrace -x bundleReleaseJsAndAssets

And it works for the new build! No crash and MMKV is working.

The maintainer says it should be fixed in RN 0.71.

But I don't understand why I get this MMKV error, instead of the error described in the RN issue.

@mrousavy
Copy link
Owner

mrousavy commented Nov 3, 2022

Awesome!

@mrousavy mrousavy closed this as completed Nov 3, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants