First of all we will say that, the main difference between Release and Debug, is that the APK release option is used to publish our application. To do this before, you must prepare your application, that is, configure, compile and test a release version.
The debug APK option helps us to debug our code, it allows us to make interrupts at runtime to examine variables and evaluate expressions, and therefore the APK is not signed.
In this article we are going to show you how to generate a signed APK.
Learn how to generate a signed APK
The first thing we have to do is make sure that our project does not have any errors, otherwise we will not be able to generate the signed APK.
When we know that there is no error we have to open the “Build” menu and in the options it gives us choose the “Generate Signed APK” option.
We can choose the option “Build APK”, however, this option does not allow us to upload the application to Google Play.
The other option allows us to generate a file or use an existing one to digitally sign the application, upload it to Google Play and make sure that only we have control over the application.
Once we give the option to “Generate Signed APK” . Here we will get a window like the following:
Here we have two options. If we already have a password created, we can load it with the option “Choose existing” and fill in the other fields with the corresponding data. If we want to create a new password or we do not have one created, click on the option “Create new”.
The following window will appear:
Here we have to fill in the following fields (the others are optional):
- Key store path: where the key we are creating will be saved.
- Password: the password1 that we want.
- Alias: the name of our key.
- Password: the password2 that we want.
- Country Code (XX): Code of our country (in our case “ES”).
We click “Accept” and Android takes care of saving the key file in the path that we have previously indicated. Be careful, we have to make sure not to lose this file, since, in case of loss, we will not be able to update our application and we will lose control over it.
Once we have done these steps, Android Studio will automatically load the key that we have generated and we can continue with the generation of the APK.
We will return to the second window shown, but this time with the fields filled in with the data that we have inserted.
We click on “Next” and the next thing it asks us is to choose the path where we want to save the APK and the type of compilation it will be (Release to publish or Debug to test and debug).
Once here, click on “Finish” and Android Studio will compile our application and save it in the indicated path. Once we carry out the process, we will see a notice in the IDE that indicates that the tasks have been carried out correctly.
If we look for the path specified above we can see that we already have our generated APK file.
We would only have to copy the file to our device where we are going to install the application or upload it to Google Play, depending on what we want to do with our android app developers.