React Native 错误无法提取本机调试元数据

Eat*_*aik 7 crash apk react-native

我使用的是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.
Run Code Online (Sandbox Code Playgroud)

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

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

rko*_*kok 9

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

修复该问题所采取的步骤:

  1. Android Studio > 工具 > SDK 管理器 > SDK 工具 > 选择并安装“NDK (Side by side)” 如果本地已经安装了 NDK 版本,则可能不需要此操作。通常在~/Android/Sdk/ndk/<versionNumber>/
  2. 在项目中的文件中/android/build.gradle,设置ndkVersion为正确的版本:
    buildscript {
        ext {
            // ...
            ndkVersion = "24.0.8215888"
         }
    }
    
    Run Code Online (Sandbox Code Playgroud)


Eat*_*aik 4

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

\n
\n

无法加载脚本。确保你\xe2\x80\x99正在运行Metor服务(运行\xe2\x80\x98react-native start\xe2\x80\x99)或者你的包\xe2\x80\x98index.android.bundle\xe2\x80 \x99 已正确打包以供发布。

\n
\n

P/S:当我这样做时,上面的错误没有出现npx react-native run-android

\n

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

\n

我所做的是,在其中添加了app/build.gradle这一行,因为我想生成一个已发布的 APK。只需从 android 文件夹运行即可。project.ext.reactbundleInRelease: truegradlew assembleRelease

\n