How to install Android Studio and start a new project

Android Studio is the official development environment for building (and testing) Android apps. We will use Android Studio to write the code for our apps, customise their appearance and fix any bugs. You can download Android Studio here.

install-android-studio.png

Install Android Studio

When installing Android Studio, it is usually fine to select the default/standard options. However, you may like to install the Android Virtual Device. The Android Virtual Device is an emulator that allows you to test your apps on virtual devices that replicate real phones and tablets.

android-studio-setup.png

It is recommended that your computer has up to 4 GB of free hard drive space to store all the parts of Android Studio and any project files.

Start a new project

Once Android Studio has been downloaded and installed, you can begin to create your first app. The first time you open Android Studio, you may be prompted to 'Import Studio settings from...'. If this happens then select Do not import settings. Next, when you reach the Welcome to Android Studio menu, click Create New Project

welcome-android-studio.png

You will have the opportunity to select a project template. Basic Activity and Empty Activity are the most commonly used project templates. The Basic Activity gives your app a readymade action bar and button, while the Empty Activity loads a blank user interface. If you are unsure which Activity type is most suitable for your project then selecting Basic Activity is usually a safe bet.

android-project-templates.png

After selecting a project template you will reach the Configure your project menu. First, you must name the app and package. The package name is the extension for a website domain (e.g. .com) followed by the names of the website and app. A package name only really matters if you intend to publish the app to the Play store so if this is not a concern then use a made-up website domain. Next, select where you would like to save the files for your app and choose the programming language. The tutorials on this website will use Kotlin. Finally, you must specify the minimum application programming interface (API) level. The API determines which Android SDK (Software Development Kit; a package of coding tools) your app will use. Higher API levels offer more advanced functions but are only supported by newer devices. At the time of writing, all apps must target at least API 30: Android 11 to be published in the Google Play store so it may be best to select this API or higher. You can keep up to date with the required API for new releases to the Google Play store by referring to Google's Policy page.

android-configure-project-kotlin.png

Click Finish to create your project.

Editing files in Code, Split and Design mode

The main workspace is called the editor. If you open Kotlin files such as MainActivity.kt then the editor will load the file in Code mode as shown below:

text.png

Code mode allows you to edit the raw text code of the file. Some file types such as XML also have other editor views called Design and Split mode. Design mode is shown below and gives you a preview of how the file will look when loaded in the app. You can edit files in Design mode by dragging and dropping the elements in the preview pane.

design.png

Split mode displays both the Code view and the Display view simultaneously so you can see the effect that changes in the code have on the layout (and vice versa) in real-time. You can toggle between the different view modes using the buttons in the top right corner of the editor.

modes.png

When in Design mode, you can add widgets (the elements of a user interface) to your app by dragging and dropping them from the Palette. For example, in the activity_main.xml file, you can open the Palette by clicking the tab near the top left-hand corner of the editor. When expanded, the palette will look like this:

palette.png

In the palette, the left column lists the different categories of widgets, while the right column contains all the widgets for you to drag and drop into the editor. We will explore the various widgets more in upcoming tutorials.

Next >>>