React Native 错误 Unable to extract native debug metadata

React Native error Unable to extract native debug metadata

我正在使用 react-native v0.65.1 并且在生成 apk 时收到很多错误

> Task :app:extractReleaseNativeSymbolTables

Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libbetter.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libc++_shared.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libfabricjni.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libfb.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libfbjni.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libfolly_futures.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libfolly_json.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libglog.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libglog_init.so because unable to locate the objcopy executable for the arm64-v8a ABI.
Unable to extract native debug metadata from D:\REACT NATIVE\test-app\test\android\app\build\intermediates\merged_native_libs\release\out\lib\arm64-v8a\libhermes-executor-common-debug.so because unable to locate the objcopy executable for the arm64-v8a ABI.

它很长,但我缩短了它,因为它是关于 arm64-v8a ABI 的。当我安装生成的 APK 并打开它时,它立即关闭。由于开发没有任何错误,不知道发生了什么。

已经研究了 2 天了,但我仍然找不到任何可以解决这个问题的方法。期待您的帮助。谢谢!

我设法找到了这个问题的原因。我使用 android studio 打开了我的项目(仅打开 android 文件夹)并尝试从那里 运行ning 它并且模拟器正在显示

Unable to load script. Make sure you’re either running a Metor service (run ‘react-native start’) or that your bundle ‘index.android.bundle’ is packaged correctly for release.

P/S: 当我做 npx react-native run-android.

时上面的错误没有出现

发现这篇非常有用的文章React Native: Unable to load script: index. android.bundle

我所做的是,在 app/build.gradle 中有这一行 project.ext.react 并添加了 bundleInRelease: true 因为我想生成一个已发布的 APK。只需 运行 gradlew assembleRelease 来自 android 文件夹。

我自己也有这个问题,最后发现是因为我没有正确连接“NDK”。

采取的修复步骤:

  1. Android Studio > 工具 > SDK 管理器 > SDK 工具 > Select 并安装“NDK(并排)” 如果本地已经安装了 NDK 版本,则可能没有必要。通常在 ~/Android/Sdk/ndk/<versionNumber>/
  2. 在项目中,在文件 /android/build.gradle 中,将 ndkVersion 设置为正确的版本:
    buildscript {
        ext {
            // ...
            ndkVersion = "24.0.8215888"
         }
    }