facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.27k stars 24.35k forks source link

couldn't find "libhermes.so" RN 0.75.4 #46995

Closed hgx closed 1 month ago

hgx commented 1 month ago

Description

I followed the tutorial to create a new project, but I am unable to run it on my Android device through Android Studio.

I haven't made any changes yet!

package.json

{
  "name": "AwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "react": "18.3.1",
    "react-native": "0.75.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.75.4",
    "@react-native/eslint-config": "0.75.4",
    "@react-native/metro-config": "0.75.4",
    "@react-native/typescript-config": "0.75.4",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.3.1",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  },
  "packageManager": "yarn@3.6.4"
}

Steps to reproduce

npx @react-native-community/cli@latest init AwesomeProject

cd AwesomeProject

npx react-native run-android So far everything is normal.

After connecting to my phone, I encountered this issue when clicking 'Run' on Android Studio

React Native Version

0.75.4

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 15.0.1
  CPU: (8) arm64 Apple M1
  Memory: 93.67 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.13.0
    path: ~/.nvm/versions/node/v20.13.0/bin/node
  Yarn:
    version: 3.6.4
    path: /usr/local/bin/yarn
  npm:
    version: 10.5.2
    path: ~/.nvm/versions/node/v20.13.0/bin/npm
  Watchman:
    version: 2024.08.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK: Not Found
  Android SDK:
    API Levels:
      - "33"
      - "34"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 34.0.0
      - 35.0.0
    System Images:
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.6
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

FATAL EXCEPTION: main
                                                                                                    Process: com.awesomeproject, PID: 31815
                                                                                                    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.awesomeproject-sznyhYwsMncTird2uCR7Pg==/base.apk"],nativeLibraryDirectories=[/data/app/com.awesomeproject-sznyhYwsMncTird2uCR7Pg==/lib/arm64, /system/lib64]]] couldn't find "libhermes.so"
                                                                                                        at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
                                                                                                        at java.lang.System.loadLibrary(System.java:1669)
                                                                                                        at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24)
                                                                                                        at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52)
                                                                                                        at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30)
                                                                                                        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:774)
                                                                                                        at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:26)
                                                                                                        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
                                                                                                        at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:24)
                                                                                                        at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:407)
                                                                                                        at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:349)
                                                                                                        at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:80)
                                                                                                        at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:51)
                                                                                                        at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:294)
                                                                                                        at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:137)
                                                                                                        at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:132)
                                                                                                        at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:47)
                                                                                                        at android.app.Activity.performCreate(Activity.java:7260)
                                                                                                        at android.app.Activity.performCreate(Activity.java:7251)
                                                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
                                                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3200)
                                                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3355)
                                                                                                        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
                                                                                                        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
                                                                                                        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2098)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loop(Looper.java:224)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7142)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:511)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)

Reproducer

none

Screenshots and Videos

No response

react-native-bot commented 1 month ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
react-native-bot commented 1 month ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
shubhamguptadream11 commented 1 month ago

@hgx Apart from Run command on Android Stdio. Are you able to build android apk on real device using npx react-native run-android.

hgx commented 1 month ago

@shubhamguptadream11

npx react-native run-android Can run on real device.

Clicking 'Run' on Android Studio doesn't work The same issue occurred when installing Build APK (s) onto the device

cortinico commented 1 month ago

Can you try to update Android Studio to ladybug? I have version

Android Studio Ladybug | 2024.2.1
Build #AI-242.21829.142.2421.12409432, built on September 24, 2024
Runtime version: 21.0.3+-79915917-b509.11 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 14.6.1

And is working fine for me.

hgx commented 1 month ago

Thanks all

This should be related to the packaging method I have chosen.

Run/Debug Configurations - Installation Options - Deploy 'APK from app bundle' After changing back to 'Default APK', it has been restored to normal