Start tracking your progress
Trailhead Home
Trailhead Home

Set Up Your Android Development Environment

What You’ll Learn

In this step, you’ll learn:

  • The software setup required for Android development.
  • How to check for preinstalled software.
  • How to install missing software.

Prerequisites

  • A Mac OS X or Windows development machine.
  • Successful completion of step 1, Install Common Components.

About the Android Development Environment

Android development components include:

  • Java Development Kit (JDK)
  • Android Studio with Gradle
  • Android SDK

You install the JDK and Android Studio, and then you install the Android SDK from within Android Studio. The Android Studio installer also installs the Gradle command line build tool.

The minimum versions Mobile SDK 7.1 requires are:

  • JDK 8 (reported as version 1.8.x at the command line)
  • Android Studio 3.4.1 with Gradle 4.6
  • Android SDK level 21 (minimum API) through 28 (target API)
Note

Note

  • On Windows, Android is required for Mobile SDK development.
  • On Mac OS X, if you don’t intend to support the Android platform, you can skip this section. You can always come back to it later if you change your mind. However, if you do skip it, you must install the iOS platform.

Install Java Development Kit

  1. To check if it is already installed, at the OS command prompt, type: java -version
    • If this command reports Java version 1.8.x or later, you’re done—proceed to the next installation. If the reported version is earlier than 1.8.x, continue to step 2.
    • If you get a “command not found” error message, continue to step 2.
  2. Go to oracle.com/java.
  3. Download and run the installer for your operating system.
  4. When the installer finishes, return to step 1.

Install Android Studio 3.4.1 with Gradle 4.6

You download installers for Android Studio tools from developer.android.com/studio.

  1. To check if it’s already installed, look for the program file: Android Studio.app on Mac OS; studio.exe or studio64.exe (or a shortcut to Android Studio) on Windows.
    • If you can’t find the program file, continue to step 2.
    • If you found the program file, run it, and then click About Android Studio in the menu. If the dialog box lists version 3.4.1 or later, skip to step 5. If it’s earlier than that version, continue to step 2.
  2. Go to developer.android.com/studio.
  3. Download and run the installer for your operating system.
  4. Step through the Android Studio Setup Wizard, then click Finish.

Install Required Android SDK Versions

Android apps specify different API levels. According to the Android documentation:
  • “Minimum API level” is the lowest API level with which your app is compatible
  • “Target API level” is the highest API level against which you’ve designed and tested your app
.

Mobile SDK 7.1 uses Android Lollipop (API 21) as its minimum and Android Pie (API 28) as its target.

  1. Open Android Studio.
  2. At the bottom of the Welcome screen, click Configure, and in the dropdown menu, click SDK Manager.
    The Configure menu with SDK Manager selected in the Android Studio Welcome screen

    The Android SDK Manager appears. In a new Android Studio installation, the SDK Manager shows a check for only the latest API level. For Mobile SDK, it’s common practice to add all versions from the minimum API to the target API.

  3. Select all API Levels from 21 to 28, then click OK. If prompted, confirm your download, then accept the license agreement and click Next.
    SDK Manager screen showing Android SDK levels 19 to 25 selected

    Installing the new API versions can take several minutes. Relax and grab a refreshing beverage.

  4. When the downloads are finished, dismiss the SDK Manager.
    Now that you’ve installed the SDK, create an emulator for testing and debugging your apps. It’s a good idea to test your Mobile SDK apps against the minimum supported API target. Let’s choose a system image that supports API 21. To get into Android Studio, create a throwaway project from the Welcome screen.
  5. From the Android Studio Welcome screen, select Start a New Android Studio Project.
  6. In the wizard, click Next as prompted to accept all defaults, then click Finish.
  7. If prompted, click Allow to accept incoming network connections.
  8. In Android Studio, click the AVD Manager tool.
    Android Studio screen showing the AVD Manager toolbar icon
  9. On the Your Virtual Devices page, click Create Virtual Device…
  10. Select a device definition, and click Next.
  11. Under Select a System Image, click x86 Images.
    In a new Android Studio installation, none of the images are downloaded.
  12. Scroll down to an image that supports API level 21, and click Download next to the image’s name.
    “Select a system image” page showing an image that supports API level 19
  13. After the download completes, select the image and click Next.
    If you like, you can change the AVD Name field to any value that helps you identify the AVD configuration. Leave the other values set to their defaults.
  14. Click Finish.
Good job! Now, when you create an Android app for Mobile SDK, you can load it into Android Studio, build it, and run it in an emulator. If Android Studio prompts to upgrade build tools or gradle files, it’s a good idea to accept. But how do you create an Android app for Mobile SDK? Read on.

Install Forcedroid

To create Android apps that are compatible with Mobile SDK, you use a node.js command-line utility named forcedroid. Forcedroid is the quickest and easiest way to create all types of Mobile SDK apps for Android. You just enter some metadata as prompted, and a few minutes later you have a fully configured Gradle project that you can open in Android Studio.

To install forcedroid, you use the npm install command.

  1. Open the Terminal app on Mac, or the command prompt on Windows.
  2. Define an ANDROID_HOME system variable that points to your installed Android SDK. For example, on a Mac, the path is typically /Users/<username>/Library/Android/sdk. Be sure to store the variable in your persistent environment settings so that you don’t have to keep retyping it.
  3. To install forcedroid, run the npm install command.
    1. On Windows, type npm install -g forcedroid and press Return.
    2. On a Mac, type sudo npm install -g forcedroid and press Return.
  4. If prompted on a Mac, enter your system password.
  5. To test your installation, type forcedroid version and press Return.
    The forcedroid version command reports version 5.1.0.

    Your command-line printout should reflect the Mobile SDK version—currently, forcedroid version 7.1.x.

To get forcedroid usage information, type forcedroid and press Return.

You’re finished! Your Android development environment is ready for Mobile SDK native app development. You can now continue either to the iOS installation step or to the hybrid installation step.

That’s it. We won’t check any of your setup. Click Verify Step to proceed to the next step in the project.

retargeting