I am new to android development and just finished my first app. I want to generate a signed apk in android studio. I read the developer docs but couldn't understand the steps. When I click on Build>Generate Signed APK...
, it shows me a dialog box asking the following:
Keystore path //with two options create new and choose existing
Keystore password
Key alias
key password
I don't get what is keystore even after googling it. When I choose create new
it asks me to select a path and locate a .jks
file which I don't have! Can anyone please explain and list the steps in order to generate a signed apk.
I dont think anyone has answered the question correctly.So, for anyone else who has the same question, this should help :
Step 1 Go to Build>Generate Signed APK>Next (module selected would be your module , most often called "app")
Step 2 Click on create new
Step 3 Basically, fill in the form with the required details. The confusing bit it is where it asks for a Key Store Path. Click on the icon on the right with the 3 dots ("..."), which will open up a navigator window asking you to navigate and select a .jks file.Navigate to a folder where you want your keystore file saved and then at the File Name box at the bottom of that window, simply enter a name of your liking and the OK button will be clickable now. What is happening is that the window isnt really asking you chose a .jks file but rather it wants you to give it the location and name that you want it to have.
Step 4 Click on Next and then select Release and Voila ! you are done.
Use Keytool binary or exe to generate a private keystore. Instructions here. You can then sign your app using this keystore. Keytool gets installed when you install Java.
NOTE: Save/backup this keystore because once you publish an app on play by signing it with this keystore, you will have to use the same keystore for any future updates. So, it's important that you back it up.
HTH.
Read this my answer here
How do I export a project in the Android studio?
This will guide you step by step to generate signed APK and how to create keystore file from Android Studio.
From the link you can do it easily as I added the screenshot of it step by step.
Short answer
If you have Key-store file then you can do same simply.
Go to Build then click on Generate Signed APK
The "official" way to configure the build.gradle file as recommended by Google is explained here.
Basically, you add a signingConfig, in where you specify the location an password of the keystore. Then, in the release build type, refer to that signing configuration.
...
android {
...
defaultConfig { ... }
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
...
Go to Build -> Generate Signed APK in Android Studio. In the new window appeared, click on Create new... button. Next enter details as like shown below and click OK -> Next. Select the Build Type as release and click Finish button. Wait until APK generated successfully message is displayed as like shown below. Click on Show in Explorer to see the signed APK file.
For more details go to this link.
Simple 5 visual steps:
Step 1: Click Build -> Generate Signed Build/APK
https://i.stack.imgur.com/k8Elg.png
https://i.stack.imgur.com/Rdb03.png
https://i.stack.imgur.com/EUlP0.png
https://i.stack.imgur.com/xUWXX.png
⚠️ Important Note: Make sure to store this keystore file safely, because same keystore file will be required for consecutive store upload.
https://i.stack.imgur.com/IKeOF.png
All done, now your Signed APK will start building and should popup on bottom right corner once available. Click locate
to get your signed APK file.
Easy?
I had the same problem. I populated the field with /home/tim/android.jks file from tutorial thinking that file would be created. and when i would click enter it would say cant find the file. but when i would try to create the file, it would not let me create the jks file. I closed out of android studio and ran it again and it worked fine. I had to hit the ... to correctly add my file. generate signed apk wizard-->new key store-->hit ... choose key store file. enter filename I was thinking i was going to have to use openjdk and create my own keyfile, but it is built into android studio
you can add this to your build gradel
android {
...
defaultConfig { ... }
signingConfigs {
release {
storeFile file("my.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
if you then need a keyHash do like this via android stdio terminal on project root folder
keytool -exportcert -alias my.keystore -keystore app/my.keystore.jks | openssl sha1 -binary | openssl base64
Note: If its a React Native project
If you open the root project folder in Android Studio, you wont see the options suggested in other answers in this page.
https://i.stack.imgur.com/61Dtw.png
Solution
Instead of the root folder I opened the packages/native/android
folder. Then only I could see the options to build signed APK.
https://i.stack.imgur.com/k8Elg.png
Official Android Documentation on the matter at hand with a step-by-step guide included on how to generate signed APK keys in Android Studio and even on how to setup the automatic APK key generation in a Gradle build.
https://developer.android.com/studio/publish/app-signing.html
Look under the chapter: Sign your release build
Dialog is slightly confusing when it asks for a Key Store Path. But this is actually where it will create Keystore. The label can be "save key store at : "
Comments inline.
https://i.stack.imgur.com/yGxNO.png
However, you can add more than one key to the same Keystore. In that case, you may also choose an existing Keystore.
Please NOTE that Google Playstore makes it quite difficult to change signing keys after the first release. So make sure you choose a location that is safe and can be remembered. Note down location and password details somewhere.
Success story sharing