Time for action – signing your app for the Google Play Store

The Android system requires all the installed applications to be digitally signed with a certificate whose private key is held by the application's developer. The Android system uses the certificate as a means of identifying the author of an application and establishing a relationship of trust between applications. The certificate is not used to control which applications the user can install. The certificate does not need to be signed by a certificate authority; it can be self-signed. Certificates can be signed on either Mac or Windows systems.

  1. On the Mac, go to Applications | Utilities | Terminal. On Windows, go to Start Menu | All Programs | Accessories | Command Prompt. Using the keytool command, add in the following lines and press Enter:
    keytool -genkey -v -keystore my-release-key.keystore -alias aliasname -keyalg RSA -validity 999999
    
    Time for action – signing your app for the Google Play Store
  2. You will be asked to enter a keystore password. From here, you will create a unique password that you, as the developer, must come up with. You will be asked to re-enter it. The remaining questions that will be asked pertain to your developer/company information, location, and so on. Fill it all in. Once you have filled in the required information, you have generated a key to sign your Android build. For more information pertaining to app signing, visit http://developer.android.com/tools/publishing/app-signing.html.
  3. Launch the Corona simulator, navigate to the application project folder and run it. Go to the Corona simulator menu bar and then to File | Build | Android. Fill in the information for Application Name, Version Code, and Version Name pertaining to your app. Specify a Package name using the Java scheme. Select Google Play from the Target App Store menu. Under Keystore, select the Browse button to locate your signed private key and then from the pull-down menu, select your generated key for your release build. You will be prompted to enter your keystore password you used to sign your application in the keytool command. Under Key Alias, choose the alias name you created for your key from the pull-down menu and enter your password when prompted. Select the Browse button to choose a location for your app build. Choose the Build button when finished:
    Time for action – signing your app for the Google Play Store

The keytool command generates the keystore as a file called my-release-key.keystore. The keystore and key are protected by the passwords you entered. The keystore contains a single key, which is valid for 999999 days. The alias is a name that you will use later to refer to this keystore when signing your application.

Your keystore password is something that you create and must remember when you build your app in Corona. There will be an option if you want to use a different password for the alias name. You can press Enter to use the same one while you're in the Terminal or Command Prompt.

When you create your build in Corona, make sure that your version number is an integer with no special characters. Also, you will have to make sure that your build.settings file includes the versionCode as well. This will be the same number as your version number. Refer to Chapter 9, Handling Multiple Devices and Networking Your Apps for more information.

The Java scheme in your build is the reverse of your domain name with the name of your product/company appended and the name of your app, for example, com.mycompany.games.mygame.

When you have built your app by using your private key and you have selected an alias name, the .apk file will be created and will be ready to be published on the Google Play Store.