Lyndon Armitage Lyndon is a general Developer. He has a keen interest in AI and Games Programming and runs a blog that he periodically updates.

Automatically Signing Android Applications

2 min read

With the release of our new PDF to Android Viewer we needed to have a reliable way of building the resulting applications for our customers to test and use. For this we use Ant as it’s the default way of building Android applications with the Android SDK, there are depreciated libraries still packaged with the SDK but there doesn’t seem to be any documentation about using them for recent versions of Android.

However, in order to install an application on an Android device the .apk file will need to be signed, this is to ensure that applications always come from the same source and can be trusted, similar to how a Java applet needs to be signed in order to access the local file system, only much more strict.

When developing using Eclipse, IntelliJ, NetBeans or any other IDE your application is signed using a debug key so you can deploy it onto your own devices for testing. This key isn’t suitable for actually releasing applications and is not allowed to be used when publishing to the Play Store.

Those familiar with pure Java and Java applets may also be familiar with the keytool and jarsigner tools that can do these operations, but you can also do the same operations in Ant by appending they keystore file location and alias to use to your file so it looks something like this:

# This file is used to override default values used by the 
Ant build system.
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.

# This file is only used by the Ant script.

# You can use this to override default values such as
#  'source.dir' for the location of your java source folder and
#  'out.dir' for the location of your output folder.

# You can also use it define how the release builds are signed 
by declaring
# the following properties:
#  '' for the location of your keystore and
#  'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 
'release' target.

A feature that is explained within the comments of the file.

However if you read the comments further you will see that on each build it will ask you for your password. To ensure that the conversion process can be automated and to remove this complexity we don’t want to be typing in our details after every conversion.

We can do this by adding in the passwords to this file, a feature that doesn’t seem to be explained on the Android documentation page that deals with signing your applications.What you add to the end of the previously mentioned file is simply:

One site that I found that listed this feature has some slightly out of date/incorrect information but you can find it here. It also isn’t updated any more but still has some useful information for anyone interested in Android development, just be aware that the Android platform is always changing so many things become obsolete, but it’s still worth checking out, especially if you want to keep backwards compatibility with older versions of the Android OS.

Hopefully you’ve found this blog post interesting and useful, if you have anything to share about automating your Android build processes feel free to leave a comment below.

This post is part of our “Android Articles Index” series. In these articles, we aim to explore android in different ways. Have a look!

Did you know...

IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?

It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page

Lyndon Armitage Lyndon is a general Developer. He has a keen interest in AI and Games Programming and runs a blog that he periodically updates.

JavaOne Exhibitor Planning with Trello

In October this year we attended and exhibited at the world’s biggest Java conference (JavaOne) which is based in San Francisco. When exhibiting at...
Sophia Howard
3 min read

4 ways to get the most from Android Developer…

I like to get down to coding and lock myself away so I can focus on getting things done without interruption. But I also...
Mark Stephens
1 min read

Top 9 Android Apps and IDE for Java Coders…

Recently at IDRsolutions my colleagues have spent a lot of time travelling to different conferences such as Oracle Code One and DevFest. One of the...
Alex Marshall
4 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2020. All rights reserved.