debug.apk 构建发布 apk 成功时 Nativescript 失败

Nativescript failed on build release apk success on debug.apk

我尝试在 android 上构建 Nativescript --release 但失败了。 这是调试结果:

* What went wrong:
A problem was found with the configuration of task ':packageF0F1F2Release'.

> File 'D:\NativeScript\key' specified for property 'signingConfig.storeFile' is not a file.

我找不到任何指南来通过 CLI 使用 nativescript 来解决这个问题。我可以使用 android studio 进行构建,但我更喜欢使用 CLI。我用 nativescript v 2.52 、 tns-core-module 2.51 和 tns-android 2.50

按照这个命令
┌─────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Usage   │ Synopsis                                                                                                              │
│ General │ $ tns build android [--compileSdk <API Level>] [--key-store-path <File Path> --key-store-password <Password> --key    │
│         │ -store-alias <Name> --key-store-alias-password <Password>] [--release] [--static-bindings] [--copy-to <File Path>]    │
└─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

在模拟器上构建 debug.apk 没有问题。谢谢。

创建发布版本需要 2 个步骤:

  1. 创建用于发布的密钥库文件

  2. 在密钥库的帮助下生成发布版本

创建用于发布的密钥库文件

keytool -genkey -v -keystore file/location/where/you/want/to/save/appkeystore_ks.jks -keyalg RSA -keysize 2048 -validity 10000 -alias YourApplicatioNameAlias

参考:https://developer.android.com/studio/publish/app-signing.html#signing-manually

在密钥库的帮助下生成发布版本

tns build android --release --key-store-path /keystore/file/location/appkeystore_ks.jks --key-store-password thepassword --key-store-alias YourApplicatioNameAlias --key-store-alias-password thepassword

参考:https://docs.nativescript.org/publishing/publishing-android-apps

此致。