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

Crash Caused in Android, with potential solution provided #431

Closed
terryatgithub opened this issue Jan 30, 2024 · 2 comments
Closed

Crash Caused in Android, with potential solution provided #431

terryatgithub opened this issue Jan 30, 2024 · 2 comments

Comments

@terryatgithub
Copy link

terryatgithub commented Jan 30, 2024

Hi! 👋
Firstly, thanks for your work on this project! 🙂

issue descriptions
since this statement

apply from: "../../node_modules/react-native/react.gradle"

would cause a crash issue in Android like this: couldn't find DSO to load: libhermes.so

potential solution

would you consider fixing it, as the react-native official recommendation here:
https://github.com/facebook/react-native/blob/7ea7d946c643f076c29bcf11b927f7569e3c516f/react.gradle#L18
image

my trial solutions(still under testing)

Today I used patch-package to patch @react-native-community/push-notification-ios@1.8.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@react-native-community/push-notification-ios/android/app/build.gradle b/node_modules/@react-native-community/push-notification-ios/android/app/build.gradle
index b857787..89613b1 100644
--- a/node_modules/@react-native-community/push-notification-ios/android/app/build.gradle
+++ b/node_modules/@react-native-community/push-notification-ios/android/app/build.gradle
@@ -1,4 +1,5 @@
 apply plugin: "com.android.application"
+apply plugin: "com.facebook.react"
 
 import com.android.build.OutputFile
 
@@ -76,7 +77,7 @@ project.ext.react = [
     entryFile: "index.js"
 ]
 
-apply from: "../../node_modules/react-native/react.gradle"
+// apply from: "../../node_modules/react-native/react.gradle"
 
 /**
  * Set this to true to create two separate APKs instead of one:

This issue body was partially generated by patch-package.

if any misunderstanding please let me know, thank you so much.

@abdymm
Copy link

abdymm commented Apr 26, 2024

oh yea, we just got it on our prod, errors after upgrading to RN 72, so its possibly coming from this lib?

@terryatgithub
Copy link
Author

we referred this comment facebook/react-native#36048 (comment)

our solution code as below for reference

    private final ReactNativeHost mReactNativeHost =
                new DefaultReactNativeHost(this) {
                @Override
                public boolean getUseDeveloperSupport() {
                    return BuildConfig.DEBUG;
                }

                @Override
                protected List<ReactPackage> getPackages() {
                    return getPackageFromMainFeature();
                }

                @Override
                protected String getJSMainModuleName() {
                    return "index";
                }

+                @Override
+                protected @Nullable JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+                   // because ReactNativeHost is overriden here, specify the HermesExecutorFactory():
+                  // refer: https://github.com/facebook/react-native/issues/36048#issuecomment-1456157287
+                 return new HermesExecutorFactory();
+            }

                @Override
                protected boolean isNewArchEnabled() {
                    return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
                }
                @Override
                protected Boolean isHermesEnabled() {
                    return BuildConfig.IS_HERMES_ENABLED;
                }
            };

    @Override
    public ReactNativeHost getReactNativeHost() {
        return mReactNativeHost;
    }

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

2 participants