首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >keytool :术语“keytool”未被识别为cmdlet、函数、脚本文件或可操作程序的名称

keytool :术语“keytool”未被识别为cmdlet、函数、脚本文件或可操作程序的名称
EN

Stack Overflow用户
提问于 2018-07-25 22:43:46
回答 3查看 13.6K关注 0票数 4

正在尝试为android构建版本。我在vscode终端中运行了keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key,但是我得到了这个错误

代码语言:javascript
运行
复制
keytool : The term 'keytool' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -val ...
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (keytool:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我运行flutter doctor -v,并使用路径获取此Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java,并将java替换为keytool(如文档中所示),但仍收到错误。我该怎么做?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-11-19 22:52:17

创建密钥库如果您已有密钥库,请跳到下一步。如果没有,请在命令行中运行以下命令来创建一个:

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

注意:将此文件保持为私有;不要将其签入公共源代码管理。

注意: keytool可能不在您的路径中。它是Java JDK的一部分,Java JDK作为Android Studio的一部分安装。对于具体的路径,运行flutter doctor -v并查看打印在‘java binary at:’之后的路径,然后使用该完全限定的路径替换java为keytool。

代码语言:javascript
运行
复制
storePassword=password from previous step
keyPassword=password from previous step
keyAlias=key
storeFile=location of the key store file, e.g. /Users/user name/key.jks

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

查看本教程的描述:https://www.youtube.com/watch?v=nGvPNG-f1-o

或者使用工具生成密钥

应用签名工具下载地址:https://shatter-box.com/knowledgebase/android-apk-signing-tool-apk-signer/

转到Java二进制文件目录: C:\Program Files\Android\Android Studio\jre\bin\java

然后键入cmd并输入enter image description here

按照视频教程生成密钥,将密钥放在您想要的任何位置,然后按照下一个教程在第一个教程中使用app包装密钥。

票数 3
EN

Stack Overflow用户

发布于 2018-07-26 01:22:13

尝试从普通的Windows命令提示符运行它

代码语言:javascript
运行
复制
D:\temp>"c:\Program Files\Android\Android Studio\jre\bin\keytool.exe" -help
Key and Certificate Management Tool

Commands:

 -certreq            Generates a certificate request
 -changealias        Changes an entry's alias
 -delete             Deletes an entry
 -exportcert         Exports certificate
...

另外,在Windows上,你不能使用~/。将其更改为Windows style path,如C:\Users\Norbert\keys,或您想要保存密钥库的任何位置。

票数 5
EN

Stack Overflow用户

发布于 2020-08-24 10:09:51

  1. 检查系统中是否正确配置了JDK如果
  2. 配置正确,检查Andriod SDK是否正确安装或
  3. 如果安装了Android SDK,则在命令提示符

中运行以下命令

keytool -list -keystore %USERPROFILE%\.android\debug.keystore

这是我们可以在FireBase中使用的调试证书。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51521738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档