A tool for writing Android applications in Mirah.
You must have the Android SDK installed with the tools/ directory placed on your $PATH. Inside tools/, the android program will allow you to download "platform" packages corresponding with Android versions you wish to develop against. You'll need to install "Android SDK Platform tools" and at least one platform revision to get started. At the time of this writing, Android 2.3.3 (revision 10) covers about 90% of the market and is a reasonable target for new applications. Once the platform tools are installed, place the SDK's platform-tools/ directory on your $PATH as well.
Additionally, you will need:
(NB: There is rudimentary support for running JRuby 1.7.2 against mirah master. See #37, follow these instructions, and beware: Here be dragons!)
While you can get OpenJDK from your distribution, it is recommended that you use something like rbenv to manage your Ruby things:
$ rbenv install jruby-1.6.8 $ rbenv --global jruby-1.6.8 $ gem install rake $ gem install mirah
Finally, to install pindah:
$ git clone git://github.com/mirah/pindah $ cd pindah/ $ gem build pindah.gemspec $ gem install pindah-0.1.3.dev.gem
gem install pindah currently installs an outdated version)
This also works with bundler; i.e. in a Gemfile like so:
source :rubygems gem 'mirah', '0.0.12' gem 'pindah', :git => 'git://github.com/mirah/pindah'
The pindah executable will create a new project starting point given a package name. A package is a namespace for your code that is often derived from a domain name you own, but can be any hierarchical identifier as long as it's unique.
$ pindah create org.example.hello_world # optional path and activity name arguments $ cd hello_world && tree . |-- AndroidManifest.xml |-- libs |-- Rakefile |-- res | |-- drawable-hdpi | | `-- ic_launcher.png | |-- drawable-ldpi | | `-- ic_launcher.png | |-- drawable-mdpi | | `-- ic_launcher.png | |-- layout | | `-- main.xml | `-- values | `-- strings.xml `-- src `-- org `-- example `-- hello_world `-- Start.mirah 12 directories, 8 files
The res/ directory contains application resources like icons, layout descriptions, and strings. The AndroidManifest.xml describes the contents and metadata of your application. The src directory contains the source code inside your package directory.
$ rake -T rake clean # Removes output files created by other targets. rake compile # Run compile rake debug # Builds the application and signs it with a debug key. rake install # Installs the newly build package. rake installd # Installs (only) the debug package. rake installi # Installs (only) the instrumented package. rake installr # Installs (only) the release package. rake installt # Installs (only) the test and tested packages. rake instrument # Builds an instrumented packaged. rake javac # Compiles R.java and other gen/ files. rake logcat # Tail logs from a device or a device or emulator rake release # Builds the application in release mode. rake release_unsigned # Builds the application in release mode. rake spec # Print the project spec rake test # Runs tests from the package defined in test.package property rake uninstall # Uninstalls the application from a running emulator or device. $ rake debug # [...] $ ls -l bin/hello_world-debug.apk -rw-r--r-- 1 user user 13222 Feb 7 23:16 bin/hello_world-debug.apk
This .apk file may be installed on a connected device or emulator with rake installd. It may even distributed for users to install themselves, though stable versions should be built with the release task.
The official documentation has more details on building. The main difference between Pindah and the standard Ant build is that the Rakefile replaces build.xml as well as all the properties files. The page above also explains how to get an emulator running for testing your application.
See Garrett for an example of a basic project.
To contribute to Pindah, you need the required environment setup. You can get tests with the following set of commands.
$ git clone email@example.com:mirah/pindah.git $ bundle install $ rake test
Problems? Suggestions? Bring them up on the Mirah mailing list or the #mirah IRC channel on freenode.
If Mirah is just too low-level and you need something more dynamic, you can try Ruboto, though be warned there is a very significant overhead it brings with it from JRuby's runtime.
Released under the Apache 2.0 license.
Copyright (c) 2011 Phil Hagelberg, Nick Plante, J.D. Huntington