Coders' Guidebook

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 app, customise its appearance and fix any bugs. You can download Android Studio here.

install-android-studio.png

Install Android Studio

When installing Android Studio, for our purposes it will be fine to select the default/standard options. You will, however, likely want to install the Android Virtual Device so you can test your app on your computer.

choose-components.png

It is recommended you have 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. When opening Android Studio for the first time, 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 Start a new Android Studio project

welcome.png

You will now have the opportunity to choose 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.

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 android 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. API 26: Android 8.0 (Oreo) is a reasonable one to go for at this stage. As time goes on and more people upgrade their devices then we can begin to transition to the higher API levels.

configure.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 Split and Design mode. Design mode is shown below and gives you an indication of how the file will look when loaded in the app. You can edit files in Design mode by dragging and dropping objects.

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 objects and other items to your app by dragging and dropping them from the Palette. For example, in the activity_main.xml file, you can open up 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 available objects, while the right column contains all the objects for you to drag and drop into the editor. We will explore these objects more in upcoming tutorials.

Next >>>