Ionic 4: todo App + firebase
Lección 37 de 38 · 37 Signing the APK Building Mobile Apps with Ionic 4 Video · Personas y blogs
37 Signing the APK Building Mobile Apps with Ionic 4 Video
in this lesson we are going to learn how we can sign the apk that we generated in the last lesson we'll start by learning how we can create a new key store with a
signing key inside it and then we'll use that key to sign the apk that we had built in the last lesson finally we'll use the tools provided to us by the Android SDK to generate the final file
that we can go ahead and upload on the Google Play Store so let's go back to visual studio code and here you can see that on the Left I have the visual studio code with the terminal open and
on the right I have the finder window with the folder opened that contains the apk file that we created in the last lesson this is because when we sign the apk file we'll need the path to this apk
file and I don't want to type the whole path manually every time so I have the apk file right here and I can drag and drop it inside the terminal to get the complete path so let's make a little
more room here and the first step is to generate the keystore and to do that we have a utility called key tool which is located inside the folder where you have installed your JDK
the command to create a new key store with a new signing key inside of it is key tool then you have to pass in the flag Genki which specifies that we want to generate a new key then you have to
pass in the flag – V followed by the flag – key store which takes in the name of the keystore file that you want to create in this case we'll call it to-do app dot key store dot key store is the
extension of the file by to do app will be the name of the file next you need to pass in a flag called alias followed by an alias that will be used to identify the key inside this key store let's call
this alias as to-do app as well next we'll use the key alig to specify the algorithm that will be used to create this key here the parameter will be RSA next we need to specify a key size which
will be 2 0 4 8 and finally we have to specify a validity this is the validity in days of this new key that we are just creating so we'll pass in 10,000 let's go ahead and press ENTER and now I am
prompted to enter a new keystore password so for now I'll just go ahead and enter a password now that I have entered the password I am prompted a few basic questions about the developer and
the organization behind this application so I'll just go ahead and answer all these questions real quick finally I just go ahead and press Enter because I want to keep the password for
my key same as the password for the keystore if you want you can specify a different password and now our new key has been created if you look inside the Explorer in Visual Studio code you can
see that I have a new file called to-do app dot key store and this is the keystore file that we have just created inside this file we have a key with the alias to-do app which is protected by a
password next we'll use this new key that we have just created to sign the apk file that we have right here to sign the apk file we have a utility called jar signer and again this utility
lives inside the jdk folder so I'll just go ahead and type in jar signer – verbose because we want to see all the information while the application is being signed followed by the flag
signing algorithm in short you have to type in s IG alg and the parameter is going to be sha-1 with RSA this is the signing algorithm then you have to specify a digest algorithm which will be
sha-1 next you have to specify a key store that you want to use to sign the application in our case we have the to-do app but keystore file and then you have to specify the path to your APK
file and for that you can either go ahead and type out the path manually or you can just go ahead and drag and drop the apk file onto the terminal and the whole path appears the last parameter
that we need to pass in is the alias that we defined while creating our key store for us the alias was to do app let's go ahead and press ENTER and we are
prompted for the password so I'll enter the same password that I defined while creating my key store and as you can see that the apk file has been signed in this step no new apk file is generated
the apk file is signed in place which means that this is apk file which has been just signed using the key store and the key that we created in the last step the name of the file however is still up
– release – unsigned not apk but this apk is actually now signed in the last step we'll use the zipa line utility to run some optimizations on this apk and
create another apk that we can upload on the Google Play Store and this utility is provided to us by the Android SDK and it lives inside the build tools folder inside your Android SDK folder
so let's go ahead and type in Sibylline dash B and you have to pass in four after that followed by the path to the file so I'll just go ahead and drag and drop the file again and then finally you
have to specify a name of the final file that you want to be created so I'll just go ahead and type in to-do app version 1.0.0 dot APK go ahead and press ENTER and the process is successful if you
open the Explorer right now in Visual Studio code you can see that I have a new file called to do app we 1.0.0 dot APK and this is the final APK file that we can go ahead and upload on the Google
Play Store so now that we have created the final deliverable apk file in the next video we'll learn how we can upload this app and submit it for review to be published on the Google Play Store