Access Keys:
Skip to content (Access Key - 0)

Building OpenRemote Android 2.0 Console

OpenRemote 2.0 Android console is one of the components in the platform checkout. Please see the instructions on the Subversion checkout if you haven't checked out the source release before.

1. Prepare Android SDK

OpenRemote Android console has been tested with Android 1.6 "Donut" (API 4), Android 2.1 "Eclair" (API 7) and Android 2.2 "Froyo" emulator (API 8). See the "Running OpenRemote Android on Device" section below for more details on device configurations that have been tested.
Java 6 SDK must be installed to compile the OpenRemote Android console.
For Windows and Linux, download Java 6 SE Development Kit from Oracle Technology Network. Mac Users, download Java 6 from Apple Support Site.

First download the Android SDK for your development platform of choice: Linux, Mac or Windows.

Unzip the SDK package to your development location. After this, you will need to download and install Android SDK components for the platforms you intend to build the OpenRemote Android console for.

To do this, start the android SDK tool without arguments:

  > unzip android-sdk_r06-mac_86.zip
  > cd android-sdk-mac_86/tools
  > ./android

This will open an user interface which allows you to choose which SDK components you want to download, shown in Image 1 below.

Image 1: Install Android SDK Components

After you finish installing the Android SDK components, you can verify the Android platform targets available for your system.

  > ./android list targets

  Available Android targets:
  id: 1 or "android-4"
       Name: Android 1.6
       Type: Platform
       API level: 4
       Revision: 3
       Skins: WVGA800 (default), HVGA, QVGA, WVGA854
  id: 2 or "android-7"
       Name: Android 2.1-update1
       Type: Platform
       API level: 7
       Revision: 2
       Skins: WQVGA432, WVGA800 (default), HVGA, QVGA, WVGA854, WQVGA400
  id: 3 or "android-8"
       Name: Android 2.2
       Type: Platform
       API level: 8
       Revision: 2
       Skins: WQVGA432, WVGA800 (default), HVGA, QVGA, WVGA854, WQVGA400
  id: 4 or "android-10"
       Name: Android 2.3.3
       Type: Platform
       API level: 10
       Revision: 1
       Skins: WQVGA432, WVGA800 (default), HVGA, QVGA, WVGA854, WQVGA400
  id: 5 or "android-11"
       Name: Android 3.0
       Type: Platform
       API level: 11
       Revision: 1

2. Update Android Project

Next update the Android project from the OpenRemote subversion checkout. Use the following (update the path parameter to subversion checkout directory):

  > ./android update project --subprojects --target android-11 --name OpenRemote \
    --path ../../OpenRemote_Boss_2_0_0_Alpha7/Android_Console_2_0_0_Alpha1/

  Updated default.properties
  Updated local.properties
  File build.xml is too old and needs to be updated.
  Updated file ../../OpenRemote_Boss_2_0_0_Alpha7/Android_Console_2_0_0_Alpha1/build.xml
  Updated default.properties
  Updated local.properties
  Added file ../../OpenRemote_Boss_2_0_0_Alpha7/Android_Console_2_0_0_Alpha1/tests/build.xml

3. Build Android Application for Emulator

Switch to your Android checkout directory and execute Ant next to build the Android APK binary:

  > cd ../../OpenRemote_Boss_2_0_0_Alpha7/Android_Console_2_0_0_Alpha1
  > ../../../trunk/Tools/apache-ant-1.7.0/bin/ant debug

  Buildfile: /home/aball/Documents/workspace_openremote/OpenRemoteConsole/build.xml
      [setup] Android SDK Tools Revision 10
      [setup] Project Target: Android 3.0
      [setup] API level: 11
      [setup]
      [setup] ------------------
      [setup] Resolving library dependencies:
      [setup] No library dependencies.
      [setup]
      [setup] ------------------
      [setup]
      [setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (11)
      [setup]
      [setup] Importing rules file: tools/ant/main_rules.xml

  -debug-obfuscation-check:

  -set-debug-mode:

  -compile-tested-if-test:

  -pre-build:

  -dirs:
       [echo] Creating output directories if needed...
      [mkdir] Created dir: /home/aball/Documents/workspace_openremote/OpenRemoteConsole/libs
      [mkdir] Created dir: /home/aball/Documents/workspace_openremote/OpenRemoteConsole/bin/classes

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

  -renderscript:
       [echo] Compiling RenderScript files into Java classes and RenderScript bytecode...

  -resource-src:
       [echo] Generating R.java / Manifest.java from the resources...

  -pre-compile:

  compile:
      [javac] /home/aball/android/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
      [javac] Compiling 87 source files to /home/aball/Documents/workspace_openremote/OpenRemoteConsole/bin/classes
      [javac] Note: Some input files use or override a deprecated API.
      [javac] Note: Recompile with -Xlint:deprecation for details.

  -post-compile:

  -obfuscate:

  -dex:
       [echo] Converting compiled files and external libraries into /home/aball/Documents/workspace_openremote/OpenRemoteConsole/bin/classes.dex...

  -package-resources:
       [echo] Packaging resources
       [aapt] Creating full resource package...
       [aapt] Warning: AndroidManifest.xml already defines debuggable (in http://schemas.android.com/apk/res/android); using existing value in manifest.

  -package-debug-sign:
  [apkbuilder] Creating OpenRemote-debug-unaligned.apk and signing it with a debug key...

  debug:
       [echo] Running zip align on final apk...
       [echo] Debug Package: /home/aball/Documents/workspace_openremote/OpenRemoteConsole/bin/OpenRemote-debug.apk

  BUILD SUCCESSFUL
  Total time: 11 seconds

4. Create Android Virtual Device (AVD)

Start the Android SDK GUI:

  > cd android-sdk-mac_86/tools
  > ./android

In the Android SDK GUI, create a new Android Virtual Device (AVD) in the 'Virtual Devices' section (shown in Image 2 below).

Image 2: Create new Android Virtual Device

In the AVD window, set up the properties of the physical device you want to emulate with the Android SDK. The details will depend on which physical device you eventually want to deploy the OpenRemote Android console application.

Image 3: Enter Virtual Device Properties

Once your AVD has been created, start the emulator as shown in Image 4 below.

Image 4: Start Android Device Emulator

5. Start OpenRemote Android Application with Emulator

Next you need to switch back to the 'tools' directory of Android SDK and start the Android Debug Bridge (ADB) to configure and install OpenRemote Android app on the emulator.

To enable controller discovery from the emulator, port forwarding must be configured:

  > cd android-sdk-mac_86/tools
  > ./adb forward tcp:2346 tcp:2346

To install your compiled OpenRemote Android application:

  > ./adb install ../../OpenRemote_Boss_2_0_0_Alpha7/Android_Console_2_0_0_Alpha1/ \
    bin/OpenRemote-debug.apk

Now you can go to the application menu in the Android emulator and start the OpenRemote Android console.


Running OpenRemote Android on Device

Following steps are only necessary if you want to deploy and test the application on hardware running Android. If you're only interested in testing with emulator, you can skip this section.

First check that the device has been set up for development by enabling the USB debugging in the device's settings.

On a default Android device this can be done by first going to the "Home" screen, then choosing "Menu" and "Settings" -> "Application" -> "Development" -> "USB Debugging". This configuration is shown below in Image 5 for a default Android 1.6 device.

Image 5: Configuring Android 1.6 Device for Development

Once done, connect the device to USB. If you're using Mac, skip the next step. If you're using Windows or Linux, you must first install the appropriate USB drivers/configuration.

Please follow the Android documentation on setting up USB with Windows and Linux.

After you've connected your device with USB, switch back to Android SDK tools. Now repeat same steps to install and application as was done with emulator.

You can first make sure your device shows up with the Android Debug Bridge:

  > cd android-sdk-mac_86/tools
  > ./adb devices

  List of devices attached
  HT94JLZ00066	device
  emulator-5554	device
  emulator-5556	device

If you've multiple devices connected (including active emulator instances), you can use the '-d' switch to direct ADB commands only to the connected USB device:

  > ./adb -d install ../../openremote/branches/project/Android_Console_2_0_0_Alphas \
    /bin/OpenRemote-debug.apk

  1157 KB/s (404349 bytes in 0.341s)
          pkg: /data/local/tmp/OpenRemote-debug.apk
  Success

Start the device and you should find OpenRemote application added to your application menu.

Next Steps

  1. Build OpenRemote Controller to service user interface to your Android panel: Building OpenRemote 2.0 Developer Releases or download pre-built developer binaries: Download OpenRemote 2.0 Developer Releases
  2. Create an account with Online Designer and design user interface and model devices
  3. Learn how to test your code changes with OpenRemote 2.0 Android unit test framework: Testing OpenRemote Android 2.0 Console

Troubleshooting

Following section lists some common errors that may occur during the Android build.

1. SetupTask cannot be found

If you receive the following error building the OpenRemote Android Console:

BUILD FAILED:
   build.xml:49: taskdef class com.android.ant.SetupTask cannot be found

Then make sure you've run the 'android update project' command correctly, as explained in Step 2 above.

When Android project is updated, the build.xml will be automatically modified and will contain path declarations to Java archives in Android SDK which include the task implementation required by Ant build tool:

...

    <!-- Custom Android task to deal with the project target, and import the proper rules.
         This requires ant 1.6.0 or above. -->
    <path id="android.antlibs">
        <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
        <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
        <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
        <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
        <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
    </path>

    <taskdef name="setup"
        classname="com.android.ant.SetupTask"
        classpathref="android.antlibs" />

...

Build.xml file of an Android project

2. @Override: method does not override a method from its superclass

If you are receiving several compile time errors such as:

  [javac]    @Override
  [javac]     ^
  [javac] .../SliderView.java:283: method does not override a method from its superclass

This is likely due to not using Java 6 compiler to build the project. There has been changes with how @Override is handled by Java compiler between Java 5 and Java 6 and OpenRemote Android Console requires Java 6 to build correctly.


See Also

External:

Added by Administrator , last edit by Administrator on Apr 14, 2011 19:04

  1. Sep 16, 2010

    Marc Fleury says:

    Do you use the ADT for eclipse or not needed?

    Do you use the ADT for eclipse or not needed?

    1. Sep 16, 2010

      Marc Fleury says:

      The path for Android update project seems to have completely changed in the rele...

      The path for Android update project seems to have completely changed in the release I am using (2.0 alpha 7)
      it does work with a path that points to the android_console directory

      1. Sep 16, 2010

        Juha Lindfors says:

        True. Updated the paths. Thanks.

        True. Updated the paths. Thanks.

    2. Sep 16, 2010

      Juha Lindfors says:

      No, not using Eclipse.

      No, not using Eclipse.

      1. Oct 07, 2010

        Marc Fleury says:

        Would love to remove the comments but can't find how.

        Would love to remove the comments but can't find how.

  2. Dec 28, 2010

    Torbjörn Österdahl says:

    The proper path to the 'adb' tool is as follows android-sdk-mac_86/platform-too...

    The proper path to the 'adb' tool is as follows

    android-sdk-mac_86/platform-tools

© 2008-2011 OpenRemote Inc. OpenRemote is a trademark of OpenRemote, Inc.
Adaptavist Theme Builder (3.3.3-conf210) Powered by Atlassian Confluence 2.10.3, the Enterprise Wiki.
Free theme builder license