How to Create a Keystore

how can i create keystore in android studio?

You have no Run configuration for your project. You can see it in the top of the screen - Add configuration. Click on it and create new Configuration.

then click on the build:
Sample Image

then click on the Generate Signed Bundle/APK:

Sample Image

After that this window will be shown, select apk and click to next:

Sample Image

Below keystore path click on create new:

Sample Image

After clicking on create new, this window will be shown. Now fill the details and select the path of keystore and keystore file name, Don't forget to add Validity for up to 1000 years:

Sample Image

Note: Place the keystore file some where safe, this file will be used for building new apks.

How to create Android Signing Certificate (keystore JKS file) programmatically instead of using Android Studio?

I decided to use this solution

val keystoreCommand = "keytool -genkey -noprompt \n" +
"-alias ${keyStore.keyAlias} \n" +
"-dname \"CN=${keyStore.certificateFirstandLastName}, OU=${keyStore.certificateOrganizationalUnit}, O=${keyStore.certificateOrganization}, L=${keyStore.certificateCityorLocality}, S=${keyStore.certificateStateorProvince}, C=${keyStore.certificateCountryCode}\" \n" +
"-keystore \"C:\\Users\\Desktop\\keystore.jks\" \n" +
"-storepass ${keyStore.keyFilePassword} \n" +
"-keypass ${keyStore.keyPassword}"

Runtime.getRuntime().exec(keystoreCommand).apply {
waitFor()
}
data class KeyStore(
val keyFilePassword: String,
val keyAlias: String,
val keyPassword: String,
val keyValidity: String,
val certificateFirstandLastName: String,
val certificateOrganizationalUnit: String,
val certificateOrganization: String,
val certificateCityorLocality: String,
val certificateStateorProvince: String,
val certificateCountryCode: String
)

Though we can do it without keytool but it's quite a lot of code to handle https://stackoverflow.com/a/45700785/7767664



Related Topics



Leave a reply



Submit