Uploading Apps to Google Play. Basic Guide (Android SDK)

After posting the Signing & uploading App guide for Marmalade SDK, we will now go with the Android one. Again, i’m getting the Android app signing tutorial as the basis. First of all, we have to generate the .keystore file. We will just reproduce the steps made in the the Marmalade tutorial:

1.- Generating a new .keystore file

We are going to to generate it using keytool.
keytool comes with the Java Development Kit (jdk) and can be called from command line, writing:

keytool

keytool has to be supplied with some arguments. There are more details here, but the basic usage should fit for us:

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

we just need to change the default .keystore file name and the alias_name by our own names.
Increasing the validity could also be a good idea, to make the keystore file valid for a longer period.

As an example: Let’s say we are requesting a keystore file for “John, the developer”:

keytool -genkey -v -keystore johnthedeveloper.keystore -alias johnDev -keyalg RSA -keysize 2048 -validity 30000

keytool will now request some additional data we have to fill, like our name, organisation unit, organisation name, city, state, and locale code.

Name: John the developer
Organisation unit: Development
Organisation name: John dev S.R.L.
City: Los santos
State: Liberty city
Locale code: 23456

once done, we have our .keystore file ready to go.

2.- Generating a signed .apk file (the easy way)

Once the .keystore file is created, all that we need is to compile our App’s .apk file signed with our private key (.keystore file). The easiest way to do this is using ant, including our keystore information into the ant.properties file, located in our Android project’s root directory. So, into the ant.properties file, add these 2 lines: key.store=key-file.keystore key.alias=keyalias the first one is the name (and optionally, the path) of the .keystore file. The second one, is the -alias parameter supplied to keytool, when we generated the .keystore file. Don’t forget to have your “key-file.keystore” file located into the project’s root directory! Once these 2 lines are added, we can run again: $ant release and we will be prompted for two passwords:

  • The keystore password (store: key-file.keystore)
  • The password for alias ‘keyalias’

After writing those two passwords (we supplied them to keytool when we generated the .keystore file), ant should return BUILD SUCCESSFUL, and we have our <AppName>-release.apk file into the bin/ directory. This APK is ready to be uploaded to Google Play! Have fun!

2b.- Generating a signed APK (the even easier way, for Eclipse users)

Another way of generating the signed .APK is using Eclipse, right clicking on the project name in the Package Explorer, and selecting Android Tools > Export Signed Application Package. On the first menu, click “Next”, then on the second one, select “Use existing keystore”. Click on “Browse” and double click on the .keystore file. Now write the keystore password, and click “Next”. Finally, select “Use existing key” and select the key alias found in the “Alias” field. Write down the password for that key alias, then Click “Next”. Select the destionation .apk file and click “Finish” 🙂

Uploading Apps to Google Play. Basic Guide (Marmalade SDK)

I’m proudly uploading my first App. (Soon i’ll post more info about it:) )
So it’s time to sign the APK and send it up. So i’ll do a quick remind of the basic steps for that.

This time i’ve chosen Marmalade to develop the App, so what we need is a signed .apk file valid for Google Play. We have to deploy it using the Marmalade Deploy Tool. So, to make the .apk suitable, we need to attach it with a key store file.

Generating a new .keystore file

So, the first thing we need is that key store file. We are going to to generate it using keytool.
keytool comes with the Java Development Kit (jdk) and can be called from command line, writing:

$ keytool

In order to generate the .keystore file that we need, keytool has to be supplied with some arguments. These arguments are detailed more deeply here, but the basic usage should fit for us:

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

we just need to change the default .keystore file name and the alias_name by our own names.
Increasing the validity could also be a good idea, to make the keystore file valid for a longer period.

keytool will now request some additional data we have to fill, like our name, organisation unit, organisation name, city, state, and locale code.

once done, we have our .keystore file ready to go.

Linking .keystore file to our marmalade project

Now we have to link this keystore file into our Marmalade project. If you are not using Marmalade, and you develop with <Android SDK> or similar instead, you can follow the remaining steps in the signing tutorial

So, in the project’s .mkb file, we have to add the following into the “deployments” section:

deployments
{
# … previous “deployments” content

# Lines related to keystore file:

android-aliasname=’alias_name’
android-keypass=’alias_password’
android-storepass=’store_password’
android-keystore=’key-file.keystore’

# Additional lines that are necessary
android-manifest=’AndroidManifest.xml’
android-pkgname=’es.example.myappname’
}

The android-aliasname and android-keystore parameters need to match with the ones passed to keytool. The android-keypass is the one we filled when keytool asked us for it.
In this case, the .keystore file is located in the project’s root directory, same as the .mkb file.

Now we can run the deploy tool again. In the third stage: Configuration, into the ‘Android’ specific options, we’ll see that the “Application keystore”, “Key alias name”, and “Private key password” fields are filled with the values we put in the .mkb file.
If these are not, review your .mkb file again; Probably there is something missing.

So, after deploying the App, we have our signed .apk file ready to be uploaded to Google Play!

The complete tutorial for Android developers can be found here
Some additional tips:

It can be useful to do a quick script using ant that modifies the AndroidManifest.xml file to set the correct versionName and versionCode values.
Elsewhere you’ll have to manage the version codes and version names by yourself. Don’t forget that every update of the App that is uploaded to Google Play has to have the same package name, and a greater versionCode and versionName

We can also add fancy icons to our app (marmalade splash logo makes our app look so poor, doesn’t it?) adding the following lines to the deployments section:
We need three .PNG images with the corresponding sizes: 72×72, 48×48 and 36×36 pixels.

android-icon=’data/icons/icon.png’
android-icon-hdpi=’data/icons/icon72.png’
android-icon-ldpi=’data/icons/icon36.png’
android-icon-mdpi=’data/icons/icon48.png’

Marmalade stupid mistakes compilation

I’ll periodically update this post with the most common mistakes that i do when developing with Marmalade, and that make me waste time.

– adding an empty .group file: Let’s say that i have a main .group file, say, MyProject.group, including all the .ui files, assets, fonts, etc. And this MyProject.group includes another SomeAssets.group file.

If SomeAssets.group is an empty file, application will compile, and work fine on x86 debug / x86 release; But when deploying to Android, App will come with an “Application has crashed unexpectedly” message on its start. Check your .group files! don’t leave one of them empty!

– Having an empty .h/.cpp file in a subproject: This case is much simpler. The app just doesn’t compile. But it displays an error related to the linker that is difficult to identify. It’s just about an empty .h or .cpp file.

– Deploying to win32 release, and not deleting the previous folder: After deploying to Windows, and executing my InnoSetup script to generate an installer, application is installed and overwrites the same folder than the last remaining installation. That means that all user data (e.g. SQLite databases) remain untouched.

– Deploying to Android, not deleting the App first: Marmalade, by default, does an “adb install -r” command when you select the “Package and install” option. That means it will re-install the App, but will keep user data untouched (databases, files, etc…in the smartphone’s SD card). So if you make changes like adding tables to the database, these changes won’t work because the new installation will keep the old database file. The solution to this is just doing “adb uninstall com.myapp.packagename” before re-installing the app.