To target the Android platform, some additional environment setup is required. Android apps can be created on Windows, macOS, and Linux.

Java

Native Android apps are compiled with the Java programming language. Download JDK8 from the download page.

Cordova is not compatible with the latest version of Java. You must install JDK8 to build Android apps with Cordova.

Gradle

Gradle is the build tool used in Android apps and must be installed separately. See the install page for details.

Android Studio

Android Studio is the IDE for creating native Android apps. It includes the Android SDK, which will need to be configured for use in the command line.

Android Studio is also used to create Android virtual devices, which are required for the Android emulator. Ionic apps can also be launched to a device.

Installing Android Studio

Download Android Studio from the Android website. More detailed installation instructions can be found in the User Guide.

Installing the Android SDK

Once installed, open Android Studio. The IDE should detect that the Android SDK needs to be installed. In the SDK Components Setup screen, finish installing the SDK. Keep note of the Android SDK Location.

Android Studio SDK Setup

By default, the latest stable SDK Platform is installed, which includes a collection of packages required to target that version of Android.

? Note: To install system images and other minor SDK platform packages, you may need to ensure Show Package Details is checked at the bottom of the SDK Manager. Android Studio SDK Manager

For future reference, the Android SDK can be managed with Android Studio in the Configure » SDK Manager menu of the Android Studio welcome screen or Tools » SDK Manager inside Android projects.

Configuring Command Line Tools

The Android SDK ships with useful command-line tools. Before they can be used, some environment variables must be set. The following instructions are for macOS and Linux. For Windows, check the documentation on setting and persisting environment variables in terminal sessions.

In ~/.bashrc, ~/.bash_profile, or similar shell startup scripts, make the following modifications:

  • Set the ANDROID_SDK_ROOT environment variable. This path should be the Android SDK Location used in the previous section.
  1. $ export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
  • Add the Android SDK command-line directories to PATH. Each directory corresponds to the category of command-line tool.
  1. # avdmanager, sdkmanager
  2. $ export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
  3. # adb, logcat
  4. $ export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
  5. # emulator
  6. export PATH=$PATH:$ANDROID_SDK_ROOT/emulator

For apksigner and zipalign, $ANDROID_SDK_ROOT/build-tools must also be added to PATH.

Creating an Android Virtual Device

Android Virtual Devices (AVDs) are blueprints that the Android emulator uses to run the Android OS. The following documentation is a quick way to get the Android emulator set up. For more detailed instructions and information, see the Android documentation.

AVDs are managed with the AVD Manager. In the Android Studio welcome screen, click Configure » AVD Manager. The AVD Manager can also be opened inside Android projects in the Tools » AVD Manager menu.

AVD Setup

Click Create Virtual Device and select a suitable device definition. If unsure, choose Pixel 2. Then, select a suitable system image. If unsure, choose Pie (API 28) with Google Play services. See Android version history for information on Android versions.

Once the AVD is created, launch the AVD into the Android emulator. Keeping the emulator running is the best way to ensure detection while developing Ionic apps for Android.

Android Emulator Booting

Set up an Android Device

Actual Android hardware can also be used for Ionic app development. But first, the device must be set up for development. The following documentation is a quick way to set up Android devices for development. For more detailed instructions and information, see the Android documentation.

  • Enable USB debugging on the device. Open Settings, navigate to Developer options, and enable USB debugging. The Developer options menu may need to be enabled first. See the Android documentation for instructions.
  • Ensure the device has permission to connect to the computer. For macOS, no additional setup is required. For Windows, install the OEM USB drivers. Verify the connection works by connecting the device to the computer with a USB cable and using the following command:
  1. $ adb devices

The device should be listed. See the full adb documentation for troubleshooting and detailed information.