为android创建密钥存储库的步骤是什么?
我需要在我的应用程序中使用谷歌地图,我不知道我错过了什么步骤。 请提供给我具体的详细步骤(我看指南没看懂)
为android创建密钥存储库的步骤是什么?
我需要在我的应用程序中使用谷歌地图,我不知道我错过了什么步骤。 请提供给我具体的详细步骤(我看指南没看懂)
当前回答
如果你不想或不能使用Android Studio,你可以使用create-android-keystore NPM工具:
$ create-android-keystore quick
这会在当前目录中生成一个新生成的密钥存储库。
更多信息:https://www.npmjs.com/package/create-android-keystore
其他回答
从命令行创建keystore文件:
Open Command line: Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved // (if you want to store keystore file at C:/ open command line with RUN AS ADMINISTRATOR) C:\Windows\system32> keytool -genkey -v -keystore [your keystore file path]{C:/index.keystore} -alias [your_alias_name]{index} -keyalg RSA -keysize 2048 -validity 10000[in days] Enter > It will prompt you for password > enter password (it will be invisible) Enter keystore password: Re-enter new password: Enter > It will ask your detail. What is your first and last name? [Unknown]: {AB} // [Your Name / Name of Signer] What is the name of your organizational unit? [Unknown]: {Self} // [Your Unit Name] What is the name of your organization? [Unknown]: {Self} // [Your Organization Name] What is the name of your City or Locality? [Unknown]: {INDORE} // [Your City Name] What is the name of your State or Province? [Unknown]: {MP} //[Your State] What is the two-letter country code for this unit? [Unknown]: 91 Enter > Enter Y Is CN=AB, OU=Self, O=Self, L=INDORE, ST=MP, C=91 correct? [no]: Y Enter > Enter password again. Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days for: CN=AB, OU=Self, O=Self, L=INDORE, ST=MP, C=91 Enter key password for <index> (RETURN if same as keystore password): Re-enter new password:
[存储C:/index.]密钥存储库)
你的任务完成了!!
在Eclipse中导出:
导出您的android包到.apk与您创建的keystore文件
右键单击要导出的包并选择导出 选择“Export Android Application > Next” 下一个 选择Use Existing Keystore > Browse .keystore file > enter password >下一步 选择Alias > enter password >下一步 浏览APK Destination > Finish
在Android Studio中:
创建密钥存储库[.keystore/。在工作室…
点击Build (ALT+B) > Generate Signed APK… 点击Create new..(ALT+C) Browse Key store path (SHIFT+ENTER) > Select path >输入name > OK 填写关于.jks/keystore文件的详细信息 下一个 您的文件 输入工作室主密码(如果不知道可以重置)> OK 选择*目标文件夹* >生成类型 发布:用于在应用商店发布 调试:用于调试应用程序 单击Finish
完成了! !
我按照本指南创建了调试密钥库。
命令如下:
keytool -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999
如果你不想或不能使用Android Studio,你可以使用create-android-keystore NPM工具:
$ create-android-keystore quick
这会在当前目录中生成一个新生成的密钥存储库。
更多信息:https://www.npmjs.com/package/create-android-keystore
我想建议自动方式与gradle仅
**在最后一个命令中定义至少一个额外的keystore参数,例如country '-dname', 'c=RU' **
apply plugin: 'com.android.application'
// define here sign properties
def sPassword = 'storePassword_here'
def kAlias = 'keyAlias_here'
def kPassword = 'keyPassword_here'
android {
...
signingConfigs {
release {
storeFile file("keystore/release.jks")
storePassword sPassword
keyAlias kAlias
keyPassword kPassword
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
}
release {
shrinkResources true
minifyEnabled true
useProguard true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
...
}
...
task generateKeystore() {
exec {
workingDir projectDir
commandLine 'mkdir', '-p', 'keystore'
}
exec {
workingDir projectDir
commandLine 'rm', '-f', 'keystore/release.jks'
}
exec {
workingDir projectDir
commandLine 'keytool', '-genkey', '-noprompt', '-keystore', 'keystore/release.jks',
'-alias', kAlias, '-storepass', sPassword, '-keypass', kPassword, '-dname', 'c=RU',
'-keyalg', 'RSA', '-keysize', '2048', '-validity', '10000'
}
}
project.afterEvaluate {
preBuild.dependsOn generateKeystore
}
这将在项目同步和构建中生成密钥存储库
> Task :app:generateKeystore UP-TO-DATE
> Task :app:preBuild UP-TO-DATE
基于@EliuX的回答,最新的工具与应用程序包兼容
echo y | keytool -genkey -keystore ./android.jks -dname "n=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias android -keypass android -storepass android -keyalg RSA -keysize 2048 -validity 2000
为了你的build.gradle
signingConfigs {
debug {
storeFile file('android.jks')
keyAlias 'android'
keyPassword 'android'
storePassword 'android'
}
}