LiveCode LessonsHow To - LiveCode Mobile Tasks Android TasksHow do I Create an Android App for Distribution?

How do I Create an Android App for Distribution?

This lesson describes how to sign an Android application and deploy it to an Android device. Two signing methods are described and screen captures are provided.

Introduction

In order to release an Android application, it first needs to be signed with a digital signature. This lesson guides you through two ways of signing your application and launching it on an Android device.

Note: This lesson requires LiveCode 4.6.2 (dp1) or later.

Consider Signing Strategies

Before signing your application for release, you should be familiar with the implications that certain signing strategies can have on the future development of your application or group of applications. If you are only planning to release one application and do not plan to provide updates, then this is something you do not have to concern yourself with in too much depth. If you plan to create and update your application, wish to develop applications that communicate with each other or share information, then you should consider signing all of your applications with the same certificate.

Note: Refer to the Android website for further information on signing strategies and signing requirements.

Getting a Self-Signed Certificate

The self-signed certificate is essentially the key you need in order to sign your application. Generating a key is not covered in this lesson, but you can get further information on creating your own private key in lesson: How do I Create a Self-Signed Certificate for an Android App? That lesson runs you through the basics of finding the required key generation tools on your machine and creating a key that could be used to sign your application.

Saving and Signing your Standalone Application

There are fundamentally two ways to create a signed application for deployment to Android devices:

1. Save as standalone with reference to the .keystore file.

2. Save as standalone, then sign the application manually.

These two approaches achieve the same objective, but there are variations in the steps involved. You can try both and test which method is best suited to your development environment.

Saving and Signing your Standalone Application (option 1)

Saving and Signing your Standalone Application (option 1)

The easiest way to save and sign your standalone application is by allowing the Standalone Builder to sign your application for you. Follow the standard steps for building a standalone Android application in the LiveCode IDE but include the location of the .keystore file in your Key path, as is shown in the figure of this step.

Once you select Save as Standalone Application... you are prompted to specify a location into which to save your application. The generation process then builds your application and prompts you further for information required by the signing process. This is the alias that you specified when creating the key, the .keystore password and the private key password.

The saved application is now signed and ready to be deployed to Android devices.

Saving your Standalone Application (option 2)

Saving your Standalone Application (option 2)

The second way to sign your application is by following the standard steps for building a standalone Android application in the LiveCode IDE but without including the location of the .keystore file in your Key path, as is shown in the figure of this step.

Once you select Save as Standalone Application... you are prompted to specify a location into which to save your application. The saved application is functionally complete, but it has not yet been signed and will not run on Android devices. You now need to sign the application manually.

Signing your Standalone Application with Jarsigner (option 2)

You can sign your application using jarsigner. This is a command line application that comes with your Java installation. If you were able to follow lesson:  How do I Create a Self-Signed Certificate for an Android App? then you should now have access to jarsigner on your machine.

The screen capture shown in this step provides you with an example of signing an application and then testing the signature to ensure that the correct signature was applied. The prompt is colored in green and the commands entered are colored in yellow. The sequence of commands used is for demonstration purposes and you will not need all of them to complete the signing process:

1. First determine that the required files are in the directory from which you are

signing your application. Use dir or ls, depending on the system you are using.

2. You need your keystore file (release.keystore) and the application that is to be

signed (TicTacToe.apk).

3. Test if your application has already been signed, using the command:

jarsigner -verify -verbose -certs TicTacToe.apk

4. The application has not been signed.

5. Sign the application, using the command:

jarsigner -verbose -keystore release.keystore TicTacToe.apk TicTacToe

Note: The syntax used here is specific to the application and keys created.

6. Enter the Keystore Passphrase.

7. The application is now being signed.

8. Test again if your application has been signed, using:

jarsigner -verify -verbose -certs TicTacToe.apk

9. Signatures are now displayed for your application.

 

 

Loading the Application onto a Device

If your device has access to the Android Market, you can download a signed application to your Android device and run it, using a USB cable.

Note: Some service providers do not allow you to access the Android Market and request the device manufacturers to disable that facility.

Download a file manager application from the Android Market and use that to download your signed application from the file system of your development machine. Then select the application you downloaded, allowing your Android device to install it.

Note: An application that was not signed will not install on your Android device.

Android Market

Android applications can be loaded onto your own device as described in this lesson. You can also distribute your applications to other users from your own website or through the Android Market. The Android Market provides features for you to manage your applications and provide updates, if needed. There are also means by which to license or charge for your applications. Information on how to release your applications to the Android Market can be found here: http://developer.android.com/guide/publishing/publishing.html.

12 Comments

Anra Registri

I have an error :

"There was an error while savin the standalone application could not compile application class"

how to fix this?

Hanson Schmidt-Cornelius

Hi Anra,

if you have followed all the instructions in this lesson, then all I can assume is that this error is being raised because you have an invalid Android Identifier.

Open your Android Standalone Application Settings for the application you are building and select the Android icon at the top of the screen.

Ensure that the content of field "Identifier" only has full stops and ASCII characters. This field should not contain white space such as tabs or spaces.

Kind Regards,

Hanson

Gerrie

Physical android device says "Application not installed" when attempting to install the standalone apk which was signed with my key.
I followed the steps above, including the steps on creating a self-signed certificate.
I uninstalled the previous app that was signed for development only.
I enabled "Unkown Sources".
I did all the above and still no luck.
What could I be missing?
My device is a Samsung Galaxy S.

Hanson Schmidt-Cornelius

Hi Gerrie,

it really sounds like the initial application that was signed with a different certificate is still hiding somewhere on your device.

Recommend having a look on the device again to make sure it has been removed properly.

Kind Regards,

Hanson

Gerald

Hi,

I do have the same problems, as Gerrie has.
Installation just stops with the message "Applacation not installed".

This message comes up, no matter if you you use a fresh install on a real device, or a fresh emulator image.
:(

Oli Brabiner

Hi, I'm a bit confused about distributing apps with the free version of livecode. If I ever got to the point where I wanted to release an app on the Android Market, am I allowed to, if I release the source code as well?

Thanks,
Oli

Hanson Schmidt-Cornelius

Hi Gerald,

hmm, I would be inclined to offer the same advice as the one offered to Gerrie.

I am assuming that you were able to load a test copy of your application onto your device, using the test button.

Maybe there was a small step you were missing when following this lesson.

Kind Regards,

Hanson

Hanson Schmidt-Cornelius

Hi Oli,

if you are releasing a LiveCode application on the Android Market and you wrote it using LiveCode Community, then yes. You can release an android application but as you pointed out you also have to release the source code.

Unfortunately it is not possible to release applications to the Apple store using LiveCode Community.

Kind Regards,

Hanson

Gerrie

Hi Gerald (and Hanson),

I have since found the solution to my "apk not installed" issue. If you did everything right but still get "apk not installed", it may be that your version of the JDK (Java Development Kit) is to blame. When I uninstalled version 7 and installed version 6, the problem was solved.
I hope this helps someone.

Regards,

Gerrie

Gerald

Thanks for the replies!
Yes, JDK 6 seems to work good so far!

gjul

dear everyone
i have create my own apps, but how can i send the apss to others.
example my apps should fill the form and send it. How can isend the form to others.

Elanor Buchanan

Hi gjul, if you want to share your apps you can put them in the store. If you have created and Android app and want to share it with people you know you can also send them the .apk file. As long as it is signed they can then install it on their device, as described in this lesson.

Kind regards

Elanor

Add your comment

E-Mail me when someone replies to this comment