AssertionError [ERR_ASSERTION]:资产必须具有哈希文件。确保安装了 expo-asset 插件

Eng*_*faq 5 android react-native expo

我在我的反应本机应用程序中添加了一些博览会包。这在调试模式下运行良好。但是当我尝试从终端或 android studio 创建发布 apk 时,我收到此错误。

AssertionError [ERR_ASSERTION]: Assets must have hashed files. Ensure the expo-asset plugin is installed.

> Task :app:createBundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:createBundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 2m 17s
Run Code Online (Sandbox Code Playgroud)

Mar*_*uez 1

我添加了以下配置metro.config.js并开始工作:

const config = {
  transformer: {
    assetPlugins: ['expo-asset/tools/hashAssetFiles'],
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false
      }
    })
  }
}

module.exports = mergeConfig(getDefaultConfig(__dirname), config)
Run Code Online (Sandbox Code Playgroud)