Nikos Maravitsas

About Nikos Maravitsas

Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. Currently, his main interests are system’s security, parallel systems, artificial intelligence, operating systems, system programming, telecommunications, web applications, human – machine interaction and mobile development.

Build Android application package file (APK) using Eclipse IDE

Android application package file (APK) compressed file that is used to install and distribute Android Applications. Remember when you install an new Application in your Android Phone (or when you run your Application in an emulator) the APK file of your project is installed on your device. APK files are really ZIP archive files. You may open APK files using any Archive program. You can also think of APK files as JAR files in Java.

In this example we’ll see how to create .apk file ready to be installed in Android device. For this tutorial, we will use the following tools in a Windows 64-bit platform:

  • JDK 1.7
  • Eclipse 4.2 Juno
  • Android SKD 4.2

1. Create a new Android Project

Here, we are going to use an existing Android Handler Project in Eclipse. In the link you are going to find details on how to create and code the project.

2. Export Unsigned Application Package

Go to the Package Explorer and locate the Project you want to export. Right Click on the Project -> Android Tools ->Export Unsigned Application Package:

export-unsigned-package

Then select the destination folder and the name of the exported package (.apk) and then save the file. When you’re done you will notice a Warning pop up. That is because android devices and emulators allow installations of digitally singed APK files (digitally signed Applications) only:

unsigned-worning

2. Export Signed Application Package

This, has an extra step of signing the APK file with a certificate. In this example we are going to create our own self signed certificate. You will see how Eclipse IDE helps us do that really quick and easy. As before, go to the Package Explorer and locate the Project you want to export. Right Click on the Project -> Android Tools ->Export Signed Application Package. The specify the project you want to sign and export and click Next.

signed-package

2.1. Select/create a new Keystore

In the next form you can choose to use an already created certificate (or keystore), or you can select to create a new one on the fly. As we said, for this example we are going to create a new one. So go ahead and:

  • Choose “Create new Keystore”.
  • Specify the location of the Keystore.
  • And provide a password for the Keystore. You will need this password to sign other applications with that specific Keystore.

And click Next.

create-new-key

2.2. Create a new Keystore

In the next window you have to fill up the form that populates the arguments of the Keystore. It’s actually pretty much the same procedure when creating a self-signed certificate (with openssl for instance).

create-new-keyfile

And click Next. Now you have to specify the name of the .apk file and the destination folder. You will also be informed on how the certificate will be used:

signed-apk-export

That’s it! Now, if you go to the destination folder you’ve specified, you will find AndroidHandlerExample.apk there ready to be installed on any Android Device or Emulator.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.
Examples Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Examples Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Examples Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close