Web Info and IT Lessons Blog...

Saturday 24 January 2015

How to build android APK file of your phonegap project?

Once you have built and tested your application in phonegap, you will need to compile it to .apk file for functionality on android phones and tablets. You can compile your phonegap project using Adobe Phonegap Build. You can signup for a free account or choose from plans given below:

Phonegap Build Plans

With free account you can build only one app using Adobe Phonegap Build. Login your phonegap Build account to get started. After you have logged in your phonegap build account, you will need to upload a zip file of your project or alternatively you can pull your project from git repository if you use git.

Phonegap upload project

Once you have uploaded your project, enter the name and description of your app and click the button 'Ready to build'.

Phonegap App Build

It will take only a moment to build your app for ios, android and windows. When your app is built successfully, click on it. Clicking your app will redirect you to a page containing the download link of your application .apk file.

Download APK File

Download the apk file of your application, install it on your android device and run your application.

How to sign you android application with a private key?

There are three steps of signing your android app: 1. Generate a private key 2. Add the private key to Phongap Build 3. Unlocking the key and rebuilding your app with private key signing.
How to generate a private key?
To generate a private key, you must have java installed on your system and environment variable (Java_Home) set. Now if you have those two things done, create an empty folder on your desktop and open your command prompt window. Navigate to the empty folder created through cmd using the cd command.

Cmd Navigate folder

Now run this command keytool -genkey -v -keystore [keystore_name].keystore -alias [alias_name] -keyalg RSA -keysize 2048 -validity 10000 After executing the command you will be asked to enter a password for the keystore and re-confirm the password, so do it. After password confirmation you will be asked a few more questions. Answer the questions with correct information.

Private Key Generate

Now in the last step of key generation you will be asked to set the password for alias_name (test_alias in my case) or return to keep the same password as keystore. After setting the password, your keystore file will be created in the folder.

How to add the private key to Phongap Build?
To add a private key to phonegap build, login your account and go to edit account in your profile image drop down. Now click on the 'Signing Key' tab in the navigation menu.

Key Signing

Click on add a key for android.

Submit Key

Give a title to the key and enter the alias_name you used before during key generation. Browse the keystore file and and submit key.

How to unlock the key?
To unlock the key click on the lock image shown below:

Unlock Key

Now enter the alias password and the keystore password you set before during key generation and click submit key button to unlock the key. This key will remain unlocked for one hour.

How to rebuild your app with private key signing
To rebuild your app with private key signing, select the key from the drop down menu and click rebuild button.

Rebuild Phonegap Project

Related Posts
Develop mobile applications in your favourite web technologies using phonegap
How to handle phonegap touch events

No comments:

Post a Comment