A Practical Guide to creating, compiling and signing an Android Application using Processing for Android.



Similar documents
Developing In Eclipse, with ADT

IOIO for Android Beginners Guide Introduction

SafeNet KMIP and Amazon S3 Integration Guide

Setting Up Your Android Development Environment. For Mac OS X (10.6.8) v1.0. By GoNorthWest. 3 April 2012

Getting Started with Android Development

Quick and Easy Solutions With Free Java Libraries Part II

SafeNet KMIP and Google Cloud Storage Integration Guide

unisys ClearPath eportal Developer 6.1 Unisys Multi-Device App Developer s Guide March

With a single download, the ADT Bundle includes everything you need to begin developing apps:

Getting Started using the SQuirreL SQL Client

Google Drive: Access and organize your files

Using Microsoft Visual Studio API Reference

Android Setup Phase 2

The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.

Login with Amazon Getting Started Guide for Android. Version 2.0

WA Continuous Integration with Jenkins- CI, Maven and Nexus. Classroom Setup Guide. Web Age Solutions Inc. Web Age Solutions Inc.

buzztouch for Android

Oracle FLEXCUBE Direct Banking Android Tab Client Installation Guide Release

Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.

SSL Configuration on Weblogic Oracle FLEXCUBE Universal Banking Release [August] [2014]

Android Development Setup [Revision Date: 02/16/11]

Android Environment SDK

Entrust Certificate Services. Java Code Signing. User Guide. Date of Issue: December Document issue: 2.0

Java Language Tools COPYRIGHTED MATERIAL. Part 1. In this part...

EasyPush Push Notifications Extension for ios

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

Installation valid SSL certificate

Hacking your Droid ADITYA GUPTA

Board also Supports MicroBridge

Tutorial on Basic Android Setup

Windows Intune Walkthrough: Windows Phone 8 Management

WA1826 Designing Cloud Computing Solutions. Classroom Setup Guide. Web Age Solutions Inc. Copyright Web Age Solutions Inc. 1

Waspmote IDE. User Guide

Setting up Sudoku example on Android Studio

How to Install Applications (APK Files) on Your Android Phone

CA Nimsoft Unified Management Portal

Practice Fusion API Client Installation Guide for Windows

Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

Installing the Android SDK

Java Client Side Application Basics: Decompiling, Recompiling and Signing

Download and Installation Instructions. Android SDK and Android Development Tools (ADT)

Setting Up a Windows Virtual Machine for SANS FOR526

Using 2Can. There are three basic steps involved in migrating all of your data from your BlackBerry to your Android phone:

FlexSim LAN License Server

Cloud Backup Express

SSO Plugin. Case study: Integrating with Ping Federate. J System Solutions. Version 4.0

Generate Android App

Android Environment SDK

Install guide for Websphere 7.0

POOSL IDE Installation Manual

Eclipse installation, configuration and operation

Getting Started with your Chromebook

webkpi SaaS ETL Connector Installation & Configuration Guide

Quote to Cloud Connecting QuoteWerks and Xero

Introduction to Android Programming (CS5248 Fall 2015)

How To Encrypt A Traveltrax Report On Gpg On A Pc Or Mac Or Mac (For A Free Download) On A Thumbdrive Or Ipad Or Ipa (For Free) On Pc Or Ipo (For An Ipo)

Primavera P6 Professional Windows 8 Installation Instructions. Primavera P6. Installation Instructions. For Windows 8 Users

TUTORIAL ECLIPSE CLASSIC VERSION: ON SETTING UP OPENERP 6.1 SOURCE CODE UNDER WINDOWS PLATFORM. by Pir Khurram Rashdi

Configuring HTTPS support. Overview. Certificates

Data Warehouse Troubleshooting Tips

HP AppPulse Mobile. Adding HP AppPulse Mobile to Your Android App

WA2262 Applied Data Science and Big Data Analytics Boot Camp for Business Analysts. Classroom Setup Guide. Web Age Solutions Inc.

Student Getting Started Guide

RHEV 2.2: REST API INSTALLATION

5 reasons to choose Streamezzo SDK over Android SDK Page 2

Outlook 2007: Managing your mailbox

Working with Portecle to update / create a Java Keystore.

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

Android Application Repackaging

SYSTEM REQUIREMENTS...

Creating an authorized SSL certificate

HTTPS Configuration for SAP Connector


Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

Version 9. Generating SSL Certificates for Progeny Web

New Technology Introduction: Android Studio with PushBot

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

1) SETUP ANDROID STUDIO

Basic Android Setup Windows Version

Android Development Tools for Eclipse

Note: Do not use these characters: < > # $ % ^ * / ( )?. &

These instructions were tested on OS X Earlier or later versions may have slight or major differences in how things work and appear.

SSL Configuration on WebSphere Oracle FLEXCUBE Universal Banking Release [September] [2013] Part No. E

XF Extracellular Flux Analyzer. Installation and Troubleshooting Guide

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3 SP02

Security in Android apps

The Social Accelerator Setup Guide

Kaspersky Password Manager

SMALL BUSINESS ACCOUNTING. Installation and Setup Guide

CEFNS Web Hosting a Guide for CS212

Intel Integrated Native Developer Experience (INDE): IDE Integration for Android*

ZeroTurnaround License Server User Manual 1.4.0

BillQuick HR Getting Started Guide2015

SC-T35/SC-T45/SC-T46/SC-T47 ViewSonic Device Manager User Guide

SAML v1.1 for.net Developer Guide

Android Tutorial. Larry Walters OOSE Fall 2011

BankLink Books Clients

Transcription:

A Practical Guide to creating, compiling and signing an Android Application using Processing for Android. By Joseph Alexander Boston http://www.jaboston.com IMPORTANT NOTE: EVERYTHING YOU INSTALL SHOULD BE THE 32 BIT VERSIONS TO AVOID INCOMPATIBILITIES LATER ON. YOU DONT NEED THE 64 BIT VERSIONS FOR ANDROID DEVELOPMENT. DO NOT TRY TO BE A HIPSTER KITTY. Step 1: Installing The Java SDK We need to install the Java SDK... Not version 7... version 6 Update 31. This can be downloaded from: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download- 1501634.html Install it to a sensible directory such as: C:\Program Files (x86)\java Later on we are going to set the path variables for this (so don t worry if you think I am missing that very important step...i am not). Step 2: Phone Drivers or Emulator You will need to know your phone model and install relevant drivers. I would suggest developing with a phone that has a good 1GHz processor and atleast 512MB of ram. Something simple without an extra keyboard that slides... like a Google Nexus phone or Samsung Galaxy S / II. Even a Motorola Razr would be suitable. You will not be able to compile anything without your computer having the relevant drivers. If you don t have your phone drivers installed... Consult your manufacturers website (Google it). A picture of the Galaxy S

Step 3: The Android SDK You will definitely need this from the word go. This has additional driver installations, feature packs for specific devices and contains the Android SDK tools and platform tools and every Android API. Infact... here is a screenshot of how the SDK manager looks. A screenshot of the SDK Manager Download the SDK Manager from here: http://developer.android.com/sdk/index.html Install it to a sensible directory such as: C:\Program Files (x86)\android SDK\

Step 4: Apache Ant For this step you will need to first download Apache Ant from: http://ant.apache.org/bindownload.cgi You will get a zip archive that looks like this: Screenshot of the Apache Ant zip archive Extract it all to a sensible directory such as: C:\Ant Where C:\Ant contains the folders bin, docs, etc, lib and a few files. This will make your life easier for the next step.

Step 5: Set your Environmental Variables. - Right click My Computer. - Click on Properties. - Go to Advanced Systems settings and click on it. - Click On the Environmental Variables Button. - In the User variables section, create a new variable named PATH and set the value to: C:\Program Files (x86)\java\jdk1.6.0_30\bin;%ant_home%\bin - In the system variable section create a new variable called ANT_HOME. Give it the value C:\Ant. There is a bin folder within each of the directories hence the \bin on the end of each in the PATH variable. %VAR_NAME_HERE% refers to a reference to any value stored in the System Variables. Understand this concept will help you greatly when trying to resolve any errors whilst following this. Check that it is working: Go to you command line and type Javac. If you have successfully entered the correct Environmental variables it will come up with a printout of some commands. Go to you command line and type ant If you have successfully entered the correct Environmental variables it will come up with a printout saying build.xml does not exist. If these test works you are successful. You may pull a success face. Now... On to downloading our old friend Processing. For those who don t know... Processing is an open source programming language and environment for people who want to create images, animations, and interactions. (and android apps). And so lets start.

Step 6: Setup Processing for Android. Download Processing from http://code.google.com/p/processing/downloads/list. This has the latest version (currently 2.0a4). Yes it is Alpha. I suggest using this Alpha version (as it is currently) as it has way more features and a lot of useful bug fixes for the way which we are using processing. Here is some of the features and bug fixes implemented: + Fixed android/code/build.xml to point at the correct SDK version. (very important). + Changing between 32- and 64- bit mode on OS X wasn't properly reloading library paths. Now it should. + Fix libraries when used with Android. Libraries can also specify an Android version by including an 'android' subfolder. + Change default package name a bit. + Switch to SDK 8 (Android 2.2) as the minimum that we're supporting. This allows us to rely on far more consistent OpenGL implementations. + Update the project files for Android SDK Tools Revision 15 (now required) http://code.google.com/p/processing/issues/detail?id=876 Well you get the idea. There are loads! They are fun to read. It teaches you about how much work has been put in to making it a viable android development platform and will make you aware of unmentioned method within the processing environment! Ok so unzip all the processing files to a suitable folder somewhere. Go to the processing exe and create a shortcut on your desktop or pin it to you taskbar or start menu so you have it easily available. You are ready... Lets get started.

Step 6: Look at your first Processing Android Application. Ok first of all download this example application from my website: http://www.jaboston.com/tutorials/simple_guide_to_processing_android/a_cats_dream.zip Inside the zipped folder is a whole processing project. What we will go through in this project is: - Playing Music - Playing Sounds - Accessing the Accelerometer. - Some useful functions for Android. Lets look at the code. Open the processing project and look at the first tab; A_Cats_Dream.pde At the top you will see we have imports (just like you would import in the standard processing mode). Under that we are creating a new Accelerometer Manager. The accelerometer manager is taken directly from the examples folder. If you click on file -> examples then go to Sensors. You will see the accelerometer example. That is where the Accelerometer Manager is taken from. The next piece of information is a button object we are creating which is being created (but not used right now). I expect that if you do want to play with the project or change it, you will want to play with the button class. This is just an example of a simple on screen switch button. If you call the show() method from any button object you have created it will draw that button on the screen. Look at the setup() function. Notice we are calling orientation(portrait). As you may have guessed, this locks the screen orientation of the application on your phone. The other function we are calling is musicplay(game_m). This function starts the playing of the game music track. You will need to modify the SoundPool.pde file if you wish to add more game music or sounds. soundsinit() is also in the SoundPool.pde. This should be called if you want to play any music(s) or sound(s). In the draw() method we are (like any other processing sketch) drawing our animation by calling the relevant methods. This acts like a while(true) loop just like a normal processing sketch.

A few other useful methods such as detectcollision() and sketchcolordepth() are there for compatibility. The methods you saw in the Accelerometer Manager example are also there (resume, pause, shakeevent and AccelerationEvent). Without these methods your accelerometer readings will not work correctly. The variables ax, ay and az are global and can be used anywhere in your sketch for a detection of the accelerometers force. At this point all I can suggest is to play around with it like you would a processing sketch and make your own apps with the tools given! Researching at http://www.processing.org will get you a lot of interesting ideas and will definitely help you brainstorm. So lets assume by this point you have created an application you wish to sign and release to the market!. Step 7: Creating a key using key tool. It is remarkably hard to understand what exactly this step means without actually undertaking it. Put simply, without generating this key, you cannot release your application to the market, as your application must be signed with this key. Here is a quote from techority on exactly how to create this key. Step 1 ) Open the terminal. Step 2 ) Type in keytool -genkey -v -keystore yourappname.keystore -alias appnamealias -keyalg RSA -keysize 2048 -validity 10000 Changing the parts I have bolded into your own information. Then hit enter. Step 3 ) You will be asked for a password; don t use anything you will forget and if you need to, write it down. If you lose the password you wont be able to update your application in the future. Step 4 ) You will asked to re-enter you password, do so, then hit enter again. Step 5 ) You ll be asked for your first and last names, key those in, hit enter again. Step 6 ) You ll be asked for the name of your organizational unit I would use Techority for mine you would likely use your studio name or, if you don t have any alternatives, your own full name. (I guess this would really be more suited to entering a division within a company, like marketing or sales, but I wouldn t remember that.) Enter again. Step 6 ) You re asked for the name your organization, I would again use Techority and you would do as you ve done above. (Studio name or full name.) Step 7 ) You ll be asked for your city of locality, I live in the city of Sydney currently, so that was my answer. Step 8 ) You ll be asked for your state or province, I m in New South Wales, so I typed that in.

Step 9 ) More location questions, you will need to key in the two letter code for your country. The United States is of course US, Australia for me was AU. Step 10 ) Finally, you will be asked to confirm all is correct and then enter your password once more, which will be the same as the one you entered and reentered in steps 3 and 4. Step 11 ) The.keystore file has been created! You can find it by clicking on the magnifying glass in the top right and doing a quick search for.keystore move it to a safe folder you have created and be sure to back that up immediately. You now have a key to sign applications with. Well done. STEP 8: Releasing the application to the market. You first need to check the AndroidManifest.xml file in your sketch folder. Click Edit with notepad (or whatever text editor you use). It will look something like this: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versioncode="7" android:versionname="1.06" package="org.longcat.the.game"> <uses-sdk android:minsdkversion="8"/> <application android:debuggable="true" android:icon="@drawable/icon" android:label="longcat"> <activity android:name=".longcat_alpha_1" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> </activity> </application> </manifest> The parts highlighted in red are the parts you will want to modify in the XML file. This is your package name and application version and release number.

The next part is quoted directly from the processing forums from the poster named ckamath in the thread/topic: https://forum.processing.org/#topic/25080000000521009 Step 1: Hit the Export button on Processing's IDE Step 2: Goto the /android folder and you will see bin, lib, res etc. (i could not find an apk file kind of freaked out the first time but not to worry all the files needed for creating the.apk are in here) Step 3: Open command prompt and get to your /android folder Step 4: Type the following command to generate your secret key that will be required for signing your application (IF YOU HAVENT ALREADY): C:\Desktop\<sketchname>\android> keytool -genkey -v -keystore <sktechname>-release-key.keystore -alias <your name or anything> -keyalg RSA -keysize 2048 -validity 10000 It will then ask you the following questions: Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: What is the name of your organizational unit? [Unknown]: What is the name of your organization? [Unknown]: What is the name of your City or Locality? [Unknown]: What is the name of your State or Province? [Unknown]: What is the two-letter country code for this unit?

[Unknown]: Is CN=name, OU=name, O=name, L=blah, ST=PA, C=US correct? [no]: yes Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days for: CN=name, OU=name, O=name, L=blah, ST=PA, C=US Enter key password for <your alias> (RETURN if same as keystore password): Re-enter new password: [Storing <appname>-release-key.keystore] ------------------------------------------------------------ This creates a <appname>-release-key.keystore file in your /android folder. ------------------------------------------------------------------------------------------------------------------ Step 5: Now we create the.apk file which is unsigned. So type in the following: C:\Desktop\<appname>\android>ant release...... BUILD SUCCESSFUL Total time: 12 seconds ----------------------------------------- You should get this in your console if the build is successful. ----------------------------------------------------------------------------------------------------------------------- Step 6: You can now see in your bin folder the.apk file named as <appname>-unsigned.apk (Yay!) Step 7: Now you will need to sign this with your secret key in order to release it on the android market. So here goes, (you can choose to copy the keystore file into your bin folder and execute the following command (too lazy to type too many characters) or keep it where it is. C:\Desktop\<sketchname>\android>jarsigner -verbose -keystore <appname>-release-key.keystore c:\desktop\<sketchname>\android\<appname>-unsigned.apk <your alias> Then you will get a bunch of statements such as Enter Passphrase for keystore:

adding: META-INF/MANIFEST.MF adding: META-INF/ALIAS.SF adding: META-INF/ALIAS.RSA...... signing: assets/comicsansms-25.vlw signing: assets/curlzmt-150.vlw signing: assets/segoeprint-60.vlw signing: res/drawable/icon.png signing: res/layout/main.xml signing: AndroidManifest.xml signing: resources.arsc signing: res/drawable-hdpi/icon.png signing: classes.dex ---------------------------------------------------------- Step 7: We are almost done! So we need to verify the previous step i.e. we need to make sure that jarsigner has signed the app correctly. So execute the following: C:\Desktop\<sketchname>\android>jarsigner -verify c:\desktop\<sketchname>\android\<appname>-unsigned.apk jar verified. You should get JAR VERIFIED else something maybe wrong. Step 8: Now to create your signed and distributable.apk file

C:\Desktop\<appname>\android>zipalign -v 4 c:\desktop\<appname>\android\<appname>-unsigned.apk <new appname>.apk Verifying alignment of <appname>.apk (4)... 50 META-INF/MANIFEST.MF (OK - compressed) 973 META-INF/ALIAS.SF (OK - compressed)... 7006548 resources.arsc (OK) 7007504 res/drawable-hdpi/icon.png (OK) 7011152 classes.dex (OK - compressed) Verification successful Now you need to upload it to the market by going to: http://market.android.com/publish You also need to have bought a publishers account. WELL DONE YOU HAVE PUBLISHED YOUR FIRST ANDROID APPLICATION! This also concludes my guide. Below are some useful links: http://www.jaboston.com https://market.android.com/developer?pub=joseph+boston http://www.youtube.com/user/thejaboston http://www.processing.org