To target the Android platform, some additional environment setup is required. Android apps can be created on Windows, macOS, and Linux.
Native Android apps are compiled with the Java programming language. Download JDK8 from the download page.
Cordova is not compatible with Java 11 yet. You must install JDK8 to build Cordova Android apps.
Gradle is the build tool used in Android apps and can be installed separately. See the install page for details.
Android Studio is the IDE for creating native Android apps. It includes the
Android Studio is also used to
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.
After the Android SDK is installed, Android Studio can be closed.
For future reference, the Android SDK can be managed with Android Studio in the Configure » SDK Manager menu.
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.
~/.bash_profile, or similar shell startup scripts, make the following modifications:
ANDROID_SDK_ROOTenvironment variable. This path should be the Android SDK Location used in the previous section.
$ 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.
# avdmanager, sdkmanager export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
# adb, logcat export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
# emulator 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 a blueprint that the Android emulator uses to run 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. The AVD Manager must be accessed inside an Android project in the Tools » AVD Manager menu. The Tools menu may not be accessible in the main screen. Create an Android project to access the full menu.
Click Create Virtual Device and select a suitable device definition. If unsure, choose Pixel 2 XL. Then, select a suitable system image. If unsure, choose the latest version. 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.
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:
$ adb devices
The device should be listed. See the full
adb documentation for troubleshooting and detailed information.