【问题标题】:Issue Generating ~\key.jks file问题生成 ~\key.jks 文件
【发布时间】:2019-08-24 23:03:31
【问题描述】:

我正在按照说明将 Flutter 应用程序部署到 Play 商店。 https://flutter.dev/docs/deployment/android

我已经达到了标题创建密钥库

系统提示我输入密码、我的姓名等,并完成该过程中的所有步骤,直到我说“是”,然后我收到以下错误

[Storing ~/key.jks]
keytool error: java.io.FileNotFoundException: ~\key.jks (The system cannot find the path specified)
java.io.FileNotFoundException: ~\key.jks (The system cannot find the path specified)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
        at sun.security.tools.keytool.Main.doCommands(Main.java:1144)
        at sun.security.tools.keytool.Main.run(Main.java:343)
        at sun.security.tools.keytool.Main.main(Main.java:336)

我不知道如何解决这个问题。

我已尝试使用以下每个命令: "C:\Program Files\Android\Android Studio\jre\bin\keytool" -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

这会导致上面的错误。

我也试过: "C:\Program Files\Java\jre-10.0.1\bin\keytool" -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

这会导致以下错误:

[Storing ~/key.jks]
keytool error: java.io.FileNotFoundException: ~\key.jks (The system cannot find the path specified)
java.io.FileNotFoundException: ~\key.jks (The system cannot find the path specified)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(Unknown Source)
        at java.base/java.io.FileOutputStream.<init>(Unknown Source)
        at java.base/java.io.FileOutputStream.<init>(Unknown Source)
        at java.base/sun.security.tools.keytool.Main.doCommands(Unknown Source)
        at java.base/sun.security.tools.keytool.Main.run(Unknown Source)
        at java.base/sun.security.tools.keytool.Main.main(Unknown Source)

我还尝试将这些目录中的每一个添加到路径中,而不是发出文档中列出的命令: keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

但这给了我这个错误: 'keytool' 未被识别为内部或外部命令,

有人遇到过这种情况吗?

【问题讨论】:

    标签: android flutter


    【解决方案1】:

    据我了解,您需要创建 keystore(.jks) 文件。

    1. goto Build-->Generate Signed Apk-->选择 apk-->选择带有文件名的路径(您要新建的)-->设置所有参数(必需 信息)-->最后选择发布并勾选v1和v2-->然后 在发布文件夹中找到您的 apk-->将此 apk 上传到 Play 商店。

    或者

    只需在下面的命令行中输入正确的路径

    keytool -genkey -v -keystore -keyalg RSA -keysize 2048 -validity 10000 -alias key

    :)

    【讨论】:

      【解决方案2】:

      在 Linux 和 MacOS 中,“~”是“我的主目录”的快捷方式,因此 ~/key.jks 扩展为例如 /home/fluttercoder/key.jks。显然,这个文件夹在 Windows 上不存在。

      在 Windows 上选择不同的文件夹,例如 c:\Users\fluttercoder\keys\,因此文件变为 c:\Users\fluttercoder\keys\key.jks。 (注意任何带有空格的 Windows 文件夹。最好避免使用它们;否则用双引号将它们括起来。)

      【讨论】:

        猜你喜欢
        • 2018-03-20
        • 1970-01-01
        • 2013-08-17
        • 1970-01-01
        • 2012-08-28
        • 2014-06-26
        • 1970-01-01
        相关资源
        最近更新 更多