Sunday, September 27, 2009

Developing in Android without Eclipse

Recently I'm back in java land, more specifically android. The past few months I've exclusively been doing scripting languages using much more primitive editors (textmate, emacs). Going back to java, I'm finding Eclipse is just getting in my way. So I decided to try and develop an android app using textmate and found it incredibly easy. It appears you have everything you need from the command line tools and all the eclipse plugin does is interface with those.

Step 1, create your project

THis couldn't be easier:

android create project --target 2 --name install_test --path . --activity InstallTest --package com.jonandkerry.install

Obviously make sure your android sdk is in your path. NOTE: if you are using SNow leopard you will need to patch your android install. See here


Step 2, build your project

The android create project tool actually builds you a very simple java skeleton project with an ant build.xml. You get several targets:

aidl
android_rules.aidl
android_rules.compile
android_rules.debug
android_rules.debug-sign
android_rules.dex
android_rules.dirs
android_rules.help
android_rules.install
android_rules.no-sign
android_rules.package
android_rules.package-resources
android_rules.release
android_rules.release-package
android_rules.release.check
android_rules.release.nosign
android_rules.resource-src
android_rules.uninstall
android_rules.uninstall.check
android_rules.uninstall.error
compile
debug
debug-sign
dex
dirs
help
install
no-sign
package
package-resources
release
release-package
release.check
release.nosign
resource-src
uninstall
uninstall.check
uninstall.error
Default target: help


obviously you see and "ant compile", "ant install", etc. Its important to note that ant compile will generate the R.java resource just like eclipse does.

Step 3, run

Couldn't be easier.

$ ant install
Buildfile: build.xml
[setup] Project Target: Android 1.6
[setup] API level: 4

dirs:
[echo] Creating output directories if needed...

resource-src:
[echo] Generating R.java / Manifest.java from the resources...
[exec] (skipping hidden file '/Users/jonathan/Development/personal/install_test/res/.DS_Store')
[exec] (skipping hidden file '/Users/jonathan/Development/personal/install_test/res/layout/.DS_Store')

aidl:
[echo] Compiling aidl files into Java classes...

compile:
[javac] Compiling 1 source file to /Users/jonathan/Development/personal/install_test/bin/classes

dex:
[echo] Converting compiled files and external libraries into bin/classes.dex...

package-resources:
[echo] Packaging resources
[aaptexec] Creating full resource package...
[null] (skipping hidden file '/Users/jonathan/Development/personal/install_test/res/.DS_Store')
[null] (skipping hidden file '/Users/jonathan/Development/personal/install_test/res/layout/.DS_Store')

debug-sign:

package:
[apkbuilder] Creating install_test-debug-unaligned.apk and signing it with a debug key...
[apkbuilder] Using keystore: /Users/jonathan/.android/debug.keystore
[apkbuilder] /Users/jonathan/Development/personal/install_test/bin/classes.dex => classes.dex

debug:
[echo] Running zip align on final apk...
[echo] Debug Package: bin/install_test-debug.apk

install:
[echo] Installing bin/install_test-debug.apk onto default emulator...
[exec] 317 KB/s (10728 bytes in 0.032s)
[exec] pkg: /data/local/tmp/install_test-debug.apk
[exec] Success

BUILD SUCCESSFUL
Total time: 5 seconds


And there you go. To be honest, I'd much rather run this stuff from the command line than watch the spinning beach ball in eclipse.

For more things you can do, see the official documentation:


And also, there is a textmate plugin that simply runs a few of these tasks:

Friday, September 25, 2009

Installing packages in Android

I've been playing around with Android quite a bit lately. One really cool thing is you can write a package (package == application) that can install other applications. Obviously this isn't done silently. A UI will be presented to the user asking them if they want to install this package and info about it.

Its basically done by sending an intent.

Intent intent = new Intent(Intent.VIEW);
intent.setDataAndType(Uri.parse("The url to your package"), "application/
vnd.android.package-archive");
startActivity(intent);

And there you go. Obviously of you want to to be notified when its complete you can also do a startActivityWithResponse call. I see this as being very powerful.

Monday, July 27, 2009

Interesting opportunities

On Monday Techcrunch released this story:

Justin.tv Opens Its API For Free, Hopes Live Video Will Explode - http://shar.es/xYpF

I don't have much experience in JustinTV except for the few events I've been to that have used it. From my understanding its like a YouTube but live video rather than uploaded and downloaded. I can't help but see the opportunities in this.

Tuesday, July 21, 2009

Venture Capital Investment Stabilizes, sort of

Venture Capital Dollars Stabilize in Second Quarter at Mid-1990s Levels

The above article shows the first increase in VC deals in a while. While the internet and clean tech are still floundering it appears VCs are all about biotech and medical devices these days. I knew I should have paid more attention in biology.

Tuesday, July 14, 2009

Joining technorati

Yes I'm joining technorati, ignore this

xfkq4bzcgs

Tuesday, January 20, 2009

Apache Camel TLP at Apache

Apache Camel was just upgraded to a top-level project. If you haven't played around with Camel you really should check it out. It abstracts any jms messaging bus and gives you a pretty interface to use cookie-cutter enterprise integration patterns. When looking at some of the patterns alarms go off on how many times I've had to hack them out on my own. Great tool to have in your pocket.

http://camel.apache.org/

Tuesday, December 2, 2008

Cherrypy + Routes with mod_wsgi

If you haven't played around with deploying your python apps using mod_wsgi, I highly recommend it. It is a very stable way to deploy your application that takes advantage of the good parts of the apache2 runtime.

Vanilla Cherrypy apps run great as wsgi applications. However, I did come across a problem when deploying a Cherrypy app with Routes. Running the application using the cherrypy server worked fine, but deploying it using apache2 + mod_wsgi always gave me the following on every request:

503 Service Unavailable

The CherryPy engine has stopped.

After some looking around the mod_wsgi project (which is well documented I must say) I found the answer here: http://code.google.com/p/modwsgi/wiki/IntegrationWithCherryPy

When running a Cherrypy app with the routes dispatcher you need to make sure you call:

cherrypy.engine.start(blocking=False)

After mounting your app. This sets the cherrypy engine state to running. After doing this everything worked great and I now have beautiful restful routes in my mod_wsgi app.