5.3.1 Android Development Environment
The required components for the Watch example for Android
are:
| Apache
Ant command line tool for compiling the Android project (available at http://ant.apache.org). The Android Java
generators were developed and tested with Ant version 1.9.3 and we recommend
using the same
version. |
| Android
SDK for the additional Android libraries and Android Emulator (available at http://developer.android.com/sdk).
|
To install Apache Ant, extract the
distribution zip file to a suitable location (for example
C:\Java\apache-ant-1.9.3). After that, set the environment variables
JAVA_HOME and
ANT_HOME:
1) | Right-click
My Computer, select Properties | Advanced system settings (or, if you are
on Windows XP, Properties | Advanced) and press the Environmental
Variables button.
|
2) | Press
New, enter JAVA_HOME as the Variable name, set the Variable
value to point to your Java SDK folder (e.g. C:\Program Files
(x86)\Java\jdk1.8.0_111), and press OK. Similarly, create another new
variable called ANT_HOME and make it point to the Apache Ant folder (e.g.
C:\Java\apache-ant-1.9.3). |
3) | Find
and select the Path variable from the System variables list, press
Edit and add a semicolon followed by the
bin folder from Apache Ant’s
installation (e.g. C:\Java\apache-ant-1.9.3\bin) to the end of the Variable
values string. |
With Ant installation
completed, you can proceed with installing the Android SDK. The Android
generators are developed and tested with Android API level 8 (Android 2.2) so
make sure that the API level 8 is included in the install. To install Android
SDK:
1) | Run
the Android SDK installer and follow the
instructions. |
2) | Start
the SDK manager and select following packages (at least) to be
installed: |
| Tools
| Android SDK
Platform-tools |
| Android
2.2 (API 8) | SDK Platform |
When you have
installed the required components, select ‘Java: Android’ as the
Generation target platform in ‘WatchModels’ property dialog
and run the ‘Autobuild’ generator. The generator produces Android
application source code and project files, and a batch file. The batch file
execution will compile the project using Ant, create and start the Android
emulator and finally install and launch the emulator. It may take a few moments
for the emulator to start and install the application when executed for the
first time. To launch the generated application in an actual Android device
instead, modify the batch file generator “_create make for Java:
Android” in MetaEdit+ to suit your purposes.
In addition to Apache Ant and Android SDK, you may also
want to install the Eclipse IDE, the Android development plug-in, and the
Eclipse plug-in for MetaEdit+ to integrate and edit the Android application
source code in Eclipse. The installation of Eclipse and MetaEdit+ plug-in has
been described in Section
5.2, ‘
Eclipse plug-in for MetaEdit+’. To
install the Android Development Toolkit, start Eclipse, select
Help | Install
New Software and enter the following URL to the location field:
http://dl-ssl.google.com/android/eclipse.
Follow the instructions to complete the installation. After the installation you
can try out the Android generation from Eclipse by following the general
instructions about using the Eclipse plug-in for MetaEdit+ in Section
5.2.
Figure 5-3. Eclipse plug-in and Android