为android创建密钥存储库的步骤是什么?
我需要在我的应用程序中使用谷歌地图,我不知道我错过了什么步骤。 请提供给我具体的详细步骤(我看指南没看懂)
为android创建密钥存储库的步骤是什么?
我需要在我的应用程序中使用谷歌地图,我不知道我错过了什么步骤。 请提供给我具体的详细步骤(我看指南没看懂)
当前回答
我疯狂地寻找如何在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 -密钥和证书管理工具。
其他回答
我想建议自动方式与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
我疯狂地寻找如何在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 -密钥和证书管理工具。
我按照本指南创建了调试密钥库。
命令如下:
keytool -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999
基于@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'
}
}
使用此命令创建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"