gpt4 book ai didi

android - react-native android 中的 gradlew assembleRelease 命令没有生成 app-release.apk

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:48:47 25 4
gpt4 key购买 nike

我想在没有 react-packager 服务器的情况下生成未签名的 app-release.apk。为此,我正在运行以下命令。

cd react-native-project-dir

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

在执行以下命令后,我在命令提示符中收到如下错误:

cd android && gradlew assemblerelease

app:processReleaseManifestessReleaseManifest

:app:processReleaseResources D:\ReactNativeProject\android\app\build\intermediates\res\merged\release\drawable-mdpi-v4\image_background_unique_2.jpg: error: Duplicate file. D:\ReactNativeProject\android\app\build\intermediates\res\merged\release\drawable-mdpi\image_background_unique_2.jpg: Original is here. The version qualifier may be implied. :app:processReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processReleaseResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt

而且我无法生成 app-release.apk 并且不明白为什么 image_background_unique_2.jpg 文件被添加到不同的文件夹中两次。

最佳答案

问题是新版本的 react-native 将 Assets bundle 在/app/build/intermediates/res/merged/release 而不是 app/src/main/res

为了解决它,我就是这样做的

rm -rf android/app/src/main/res/drawable-*

现在使用此命令 bundle Assets :

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle -- Assets 目标 android/app/build/intermediates/res/merged/release/

注意上面命令中更新的 --assets-dest。之后组装 APK 工作正常!

react-native run-android --variant=release

关于android - react-native android 中的 gradlew assembleRelease 命令没有生成 app-release.apk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45096794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com