Installing Android Studio
- Navigate to the Android developers site and follow the instructions to download and install Android Studio.
- Accept the default configurations for all steps.
- Make sure that all components are selected for installation.
- After finishing the install, the Setup Wizard will download and install some additional components. Be patient, this might take some time depending on your Internet speed, and some of the steps may seem redundant.
- When the download completes, Android Studio will start, and you are ready to create your first project. Troubleshooting: If you run into problems with your installation, check the latest documentation, programming forums, or get help from you instructors.
Create “Hello World” app
In this task, you will implement the “Hello World” app to verify that Android studio is correctly installed and learn the basics of developing with Android Studio.
Create the “Hello World” app
1. Launch Android Studio if it is not already opened.
2. In the main Welcome to Android Studio window, click “Start a new Android Studio project”.
3. In the New Project window, give your application an Application Name, such as “Hello World”.
4. Verify the Project location, or choose a different directory for storing your project.
5. Choose a unique Company Domain.
- Apps published to the Google Play Store must have a unique package name. Since domains are unique, prepending your app’s name with your or your company’s domain name is going to result in a unique package name.
- If you are not planning to publish your app, you can accept the default example domain. Be aware that changing the package name of your app later is extra work.
6. Verify that the default Project location is where you want to store your Hello World app and other Android Studio projects, or change it to your preferred directory.
7. On the Target Android Devices screen, “Phone and Tablet” should be selected. And you should ensure that API 15: Android 4.0.3 IceCreamSandwich is set as the Minimum SDK. (Fix this if necessary.)
- At the writing of this book, choosing this API level makes your “Hello World” app compatible with 97% of Android devices active on the Google Play Store.
- These are the settings used by the examples in this book.
8. Click Next.
9. If your project requires additional components for your chosen target SDK, Android Studio will install them automatically. Click Next.
10. Customize the Activity window. Every app needs at least one activity. An activity represents a single screen with a user interface and Android Studio provides templates to help you get started. For the Hello World project, choose the simplest template (as of this writing, the “Empty Activity” project template is the simplest template) available.
11. It is a common practice to call your main activity MainActivity. This is not a requirement.
12. Make sure the Generate Layout file box is checked (if visible).
13. Make sure the Backwards Compatibility (App Compat) box is checked.
14. Leave the Layout Name as activity_main. It is customary to name layouts after the activity they belong to. Accept the defaults and click Finish.
After these steps, Android Studio:
- Creates a folder for your Android Studio Projects.
- Builds your project with Gradle (this may take a few moments). Android Studio uses Gradle as it’s build system. See the Configure your build developer page for more information. Opens the code editor with your project.
- Displays a tip of the day.
- Android Studio offers many keyboard shortcuts, and reading the tips is a great way to learn them over time.
The Android Studio window should look similar to the following diagram:
You can look at the hierarchy of the files for your app in multiple ways.
1. Click on the Hello World folder to expand the hierarchy of files (1),
2. Click on Project (2).
3. Click on the Android menu (3).
4. Explore the different view options for your project. Note: This book uses the Android view of the project files, unless specified otherwise.