Appendix: Setup

Contents:

The practicals in this book assume that you are using the latest version of Android Studio, and some of the practicals require at least Android Studio 3.0. For example, the Performance chapters teach you how to use the Android Profiler tools.

This page summarizes how to set up the latest version of Android Studio.

If you need more help, see Install Android Studio and Run Hello World in the Android Developer Fundamentals course and the resources at the end of this page.

What you should already KNOW

You should be able to:

  • Create and run an Android app using Android Studio.

What you will LEARN

  • How to set up your environment for the Advanced Android Development practicals.

What you will DO

  • Install Android Studio 3 or later.
  • Update Android Studio, if necessary.
  • Update the SDK for building and running the apps you create in the Advanced Android Development course.
  • If necessary, set up your mobile device to run and debug Android apps from your computer.

App overview

You can use the finished WordListSQLInteractive app from the Android Developer Fundamentals course to test your setup, or you can use any other app that's not simplistic.

Task 1. Set up your environment

1.1 Get Android Studio 3 or later

What follows are the summary instructions for installing Android Studio 3, for each platform that supports Android Studio.

Note that you can keep two independent versions of Android Studio on your development machine, if you want to.

Windows:

  1. Download Android Studio for Windows.
  2. Unpack the zip file.
  3. Rename the resulting folder to something unique like "Android Studio 3."
  4. Move the folder to a permanent location, such as next to your existing Android Studio install in C:\Program Files\Android\.
  5. Inside C:\Program Files\Android\Android Studio 3\bin\, launch studio64.exe (or if you're on a 32-bit machine, launch studio.exe).
  6. To make the version available in your Start menu, right-click studio64.exe and click Pin to Start Menu.

Mac:

  1. Download Android Studio for Mac.
  2. Unpack the zip file.

    Note: If you download version 2.3 or lower, the app name does not include the version number. Rename the new version before moving it into your apps directory. Otherwise, you might override your existing version of Android Studio.

  3. Drag the app file into your Applications folder.

  4. Launch the app.

Linux:

  1. Download Android Studio for Linux.
  2. Unpack the zip file.
  3. Rename the resulting folder to something unique like "android-studio-3".
  4. Move the folder to wherever you have your stable version, such as within /usr/local/ for your user profile, or within /opt/ for shared users.
  5. Open a terminal, navigate into android-studio-3/bin/, and execute studio.sh.
  6. To make the new version available in your list of apps, select Tools > Create Desktop Entry from the Android Studio menu bar.

1.2 Update Android Studio

  1. Open Android Studio.
  2. If you are not prompted to update, select Android Studio > Check for updates....
  3. Continue to check for updates, until you see a dialog saying that you have the latest version.  Check for updates until you see a dialog saying that you have the latest version.

1.3 Build an app to verify your Android Studio installation

You probably need to install additional SDK downloads before your app builds.

  1. Open Android Studio, then open an existing app of some complexity, such as WordListSQLInteractive.

    When you build an app that you built with a previous version of Android Studio, you may get errors about components and libraries that are missing.

  2. Click the links as prompted by the error messages, and install the needed components.

  3. Update Gradle, if you're prompted to do so.

  4. Follow the prompts until your app finishes building.

1.4 Run the app on a mobile device

  1. On your mobile device, enable developer options, if they are not already enabled. To find these settings on the device, open Settings > Developer options.

    On Android 4.2 and higher, the Developer options screen is hidden by default. To make the screen visible, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom.

  2. In Developer options, enable USB Debugging. This is necessary for your development machine to see and access your mobile device.

  3. Connect the mobile device to your development computer with a USB data cable.
  4. In Android Studio, click Run.
  5. You may be prompted to install HAXM and emulator images. If you have been using several emulator images, this installation can take a while. Your largest update may be over 1 GB and will take some time to download even on a fast connection. You can postpone the system image downloads and run them later from the AVD manager.
  6. After installation, choose your device and run the app.

1.5 Run the app on an emulator

  1. If the app is running on your device, stop it.
  2. Run the app again, choosing an emulator. Your emulator may update before it runs your app.

    If you don't have an emulator, click Create Virtual Device in the Select Deployment Target dialog. Choose a phone and an existing system image, if you have one, because additional system images are large to download.

  3. Make sure that the app runs correctly.

1.6 Create and run Hello World

To make sure that you're ready to work, create and run a Hello World app:

  1. Create a new project using the Basic Activity.
  2. Accept all the defaults.
  3. Run the app on any device or emulator.

Learn more

results matching ""

    No results matching ""