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

App crashes on android release build #806

Open
itsnyx opened this issue Jul 6, 2024 · 3 comments
Open

App crashes on android release build #806

itsnyx opened this issue Jul 6, 2024 · 3 comments

Comments

@itsnyx
Copy link

itsnyx commented Jul 6, 2024

Hello, im using react-native 0.74.3
and everything works ok in debug mode but app crashes in release build and here is the log cat :

error: MAJOR_VERSION not found in .env, js engine: hermes
2024-07-06 21:20:13.008 21766-21825 ReactNativeJS           app.myapp  Invariant Violation: "myApp" has not been registered. This can happen if:
                                                                                                    * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
                                                                                                    * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
2024-07-06 21:20:13.023 21766-21826 AndroidRuntime          app.myapp               
E  FATAL EXCEPTION: mqt_native_modules
  Process: app.myapp , PID: 21766
  com.facebook.react.common.JavascriptException: Error: MAJOR_VERSION not found in .env, js engine: hermes, stack:
                accessEnv@1:2958807
                getAppVersionName@1:2958848
                anonymous@1:2963752
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:2959392
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:2473344
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:2467551
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:2464542
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:2280849
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:1680042
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168619
                metroRequire@1:167902
                anonymous@1:178899
                loadModuleImplementation@1:169385
                guardedLoadModule@1:168576
                metroRequire@1:167902
                global@1:166966
                
                 at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(SourceFile:76)
                 at java.lang.reflect.Method.invoke(Native Method)
                 at com.facebook.react.bridge.JavaMethodWrapper.invoke(SourceFile:155)
                 at com.facebook.react.bridge.JavaModuleWrapper.invoke(SourceFile:20)
                 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(SourceFile:1)
                 at android.os.Looper.loop(Looper.java:223)
                 at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(SourceFile:38)
                 at java.lang.Thread.run(Thread.java:923)
2024-07-06 21:20:13.070 21766-21766 OrientationModule       app.myapp                  D  onActivityPaused

MAJOR_VERSION is my first variable inside env and since it cant read that it will crash !

@itsnyx
Copy link
Author

itsnyx commented Jul 8, 2024

this line def enableProguardInReleaseBuilds = false
fixes it

@sonbxcq
Copy link

sonbxcq commented Jul 9, 2024

Problems with Proguard
When Proguard is enabled (which it is by default for Android release builds), it can rename the BuildConfig Java class in the minification process and prevent React Native Config from referencing it. To avoid this, add an exception to android/app/proguard-rules.pro:

-keep class com.yourpackage.BuildConfig { *; }

com.yourpackage should match the package value in your app/src/main/AndroidManifest.xml file.

@MahmoudMabrok
Copy link

@sonbxcq This should be added to README of lib.

Thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants