Running and Debugging Your Android Application Remotely

From Appmethod Topics
Jump to: navigation, search

Go Up to Android Mobile Application Development

Note: This page describes how to debug an Android app using an Android emulator. This information is not restricted to Android emulators; you can use this method with Android devices that are connected to a second machine as described here.

Android emulators require a lot of machine resources, especially CPU. Running an Android emulator and Appmethod side by side on the same PC might not be desirable, depending on the resources of your development PC. This is particularly true when you run Appmethod on a virtual machine (VM).

If you need to run an Android emulator, and using the development PC is not an option, you can optionally run your Android emulator on a second machine, and have your development PC connected to this second machine using SSH, so that Appmethod can detect and use any Android emulator running on that second machine.

See Also: Video Instructions

Prepare Your Remote Machine

The machine where you run an Android emulator can be any system supported by the Android SDK: Windows, Mac OS X, or Linux. It is recommended that this machine is on the same network as your development PC, for performance and configuration reasons, but it might be possible to use any machine if firewalls and routing are configured correctly.

On the remote machine:

  1. Install and enable an SSH server solution. See:
    • Windows lacks built-in SSH support, check here for a list of SSH server solutions that you can install on your remote machine. FreeSSHd has been found to work.
    • On Mac OS X go to System Preferences -> Sharing and enable "Remote Login". See also: How to enable SSH on Mac OS X.MacOSXReoteLogin.png
  2. Install the Android SDK.
    If the remote machine runs Windows, see Installing the JDK/SDK/NDK (only the JDK & SDK is required).
    For other operating systems, follow the directions for the JDK and then extract the SDK into a convenient folder.
  3. Create and start an Android emulator to use.
    If the remote machine runs on Windows, see Creating an Android Emulator.
    On other operating systems you need to run Android, which is found in the /sdk/tools folder where you extracted the Android SDK. From there you can access the AVD Manager from Tools.
  4. Kill the ADB server:
    1. Open a terminal window and navigate to the Android SDK folder that contains the ADB executable (sdk\platform-tools directory).
    2. Enter: adb.exe kill-server (Windows) or ./adb kill-server (Mac OS X, Linux).

Configure Your Development PC

On your development PC:

  1. Install the PuTTY SSH client.
  2. Open PuTTY and create a connection to your remote machine.
  3. Select Connection > SSH > Tunnels and add a local/auto port forwarding for:
    • 5555 to localhost:5555
    • 5554 to localhost:5554
    PuTTY Tunnel Settings.png
  4. Save your connection and open it.
  5. Enter the SSH login credentials for your remote machine.
  6. Keep this terminal window open as it maintains the connection to the remote machine. You can minimize it.

Once you are logged in, you need to restart the ADB server running on your development PC:

  1. Open a terminal window and navigate to the Android SDK folder that contains the ADB executable (sdk\platform-tools directory).
  2. Enter: adb.exe kill-server&adb start-server

Your Android emulator running on the remote machine should now appear on the Project Manager.

Note: Android emulators installed in your remote machine but not running cannot be displayed on the Project Manager; only running emulators are displayed.

See Also