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:
then click on the Generate Signed Bundle/APK:
After that this window will be shown, select apk and click to next:
Below keystore path click on create new:
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:
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
Push Notifications in Android Platform
How to Save Recyclerview'S Scroll Position Using Recyclerview.State
How to Get Uri from an Asset File
How to Get the Width and Height of an Android.Widget.Imageview
Android Get Real Path by Uri.Getpath()
The Setmobiledataenabled Method Is No Longer Callable as of Android L and Later
Android Intent for Twitter Application
Android: How to Auto-Restart an Application After It Has Been "Force Closed"
Android: Upgrading Db Version and Adding New Table
How to Get Pixel Color in Android
How to Use Disk Caching in Picasso
Android: How to Validate Edittext Input
Using Intent in an Android Application to Show Another Activity