本文介绍了keytool:术语“ keytool”不被识别为cmdlet,函数,脚本文件或可操作程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图为Android构建发行版。我在vscode终端中运行 keytool -genkey -v -keystore〜/ key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias
key
但我得到了此错误

trying to build release for android. I ran keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -aliaskey in the vscode terminal but I get this error

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二进制文件:C:\Program Files\Android\Android Studio\jre\bin\java 使用路径,并用keytool替换java(如文档中所示),但仍会出错。
我该怎么办

I ran flutter doctor -v and get thisJava binary at: C:\Program Files\Android\Android Studio\jre\bin\java use the path and replace java with keytool(as in the documentation) but still get error.what do I do

推荐答案

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

Create a keystoreIf you have an existing keystore, skip to the next step. If not, create one by running the following at the command line:

keytool -genkey -v -keystore〜/ key.jks -keyalg RSA -keysize 2048 -validity 10000-别名密钥

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

注意:将此文件设为私有;

Note: Keep this file private; do not check it into public source control.

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

Note: keytool may not be in your path. It is part of the Java JDK, which is installed as part of Android Studio. For the concrete path, run flutter doctor -v and see the path printed after ‘Java binary at:’, and then use that fully qualified path replacing java with keytool.

从应用程序中引用密钥库
创建一个名为appdir / android / key.properties的文件,其中包含对密钥库的引用:

Reference the keystore from the appCreate a file named appdir/android/key.properties that contains a reference to your keystore:

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
    }
}

检查本教程的说明:

或使用工具生成密钥

从以下位置下载应用签名工具:

Download app Signing tool from : https://shatter-box.com/knowledgebase/android-apk-signing-tool-apk-signer/

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

Go To the Directory Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java

然后输入cmd并输入

Then type cmd and Enterenter image description here

按照视频教程生成密钥,将密钥放置在所需的位置,然后按照下一个教程将密钥与应用程序一起包装在第一个教程中。

Follow Along to the video tutorial to generate the key, place the key anywhere you want then follow the next tutorial to wrap the key with app with the 1st tutorial.

这篇关于keytool:术语“ keytool”不被识别为cmdlet,函数,脚本文件或可操作程序的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 20:18