为android创建密钥存储库的步骤是什么?
我需要在我的应用程序中使用谷歌地图,我不知道我错过了什么步骤。 请提供给我具体的详细步骤(我看指南没看懂)
为android创建密钥存储库的步骤是什么?
我需要在我的应用程序中使用谷歌地图,我不知道我错过了什么步骤。 请提供给我具体的详细步骤(我看指南没看懂)
当前回答
使用此命令创建debug.keystore
keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
其他回答
我想建议自动方式与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
使用此命令创建debug.keystore
keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
从命令行创建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
完成了! !
在Android Studio中签名应用
要在Android Studio的发布模式下签署应用,请遵循以下步骤:
1-在菜单栏上,单击“Build > Generate Signed APK”。
2-在Generate Signed APK Wizard窗口中,单击Create new创建一个新的密钥库。 如果您已经有一个密钥存储库,请转到步骤4。
3-在“New Key Store”窗口中,提供如图所示的所需信息 你的密钥应该至少有效25年,所以你可以在应用的生命周期内使用相同的密钥签署应用更新。
4—在“Generate Signed APK Wizard”窗口中,选择密钥库和私钥,并输入两者的密码。然后单击“下一步”。 5-在下一个窗口中,为签名的APK选择一个目的地,然后单击Finish。
参考
http://developer.android.com/tools/publishing/app-signing.html
我疯狂地寻找如何在shell中使用单行命令生成.keystore,以便从另一个应用程序运行它。是这样的:
echo y | keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias business -keypass kpi135 -keystore /working/android.keystore -storepass ab987c -validity 20000
dname is a unique identifier for the application in the .keystore cn the full name of the person or organization that generates the .keystore ou Organizational Unit that creates the project, its a subdivision of the Organization that creates it. Ex. android.google.com o Organization owner of the whole project. Its a higher scope than ou. Ex.: google.com c The country short code. Ex: For United States is "US" alias Identifier of the app as an single entity inside the .keystore (it can have many) keypass Password for protecting that specific alias. keystore Path where the .keystore file shall be created (the standard extension is actually .ks) storepass Password for protecting the whole .keystore content. validity Amout of days the app will be valid with this .keystore
它对我来说工作得很好,它不要求控制台中的任何其他东西,只是创建文件。有关更多信息,请参阅keytool -密钥和证书管理工具。