Building your first app with Android Studio

by Gisle Hannemyr

Mumble

Table of contents

Introduction

This tutorial provides step by step instructions about creating a “Hello World”-app native app for Android using Android Studio ver. 4.0.1. (aug. 2020)

There are instructions in a YouTube-video (10:23 mins): Android and Android Studio: Getting Started.

Before you start, make sure you've set up a virtual device, or connected a physical one over USB.

Create minimal app

To create a minimal new project, first open Android Studio.

Then go through the following steps:

  1. Navigate to File » New » New Project.
  2. In the modal “Choose your project”, select Phone and Table » Basic Activity. Click “Next”.
  3. Now, configure the project, fill in the form with the following values:
    • Name: “Hello World”.
    • Package name: “com.example.helloworld” (use own domain instead of “com.example”).
    • Save location: Use default.
    • Language: “Java”
    • Minimum API Level: “API 22: 5.1 (Lollipop)”.
  4. Click “Finish”.

Now, studio will launch your app and start doing a gradle sync. This will run two background processes. This will take some time. The speed depends on the hardware – on my HP Pavillion about 7 minutes, on my Dell half tower about 7 seconds..

During this sync, Windows defender will pop up a message requesting access. Grant it.

After syncing, it will set up project, and then start indexing. This will also take time.

To test the app, select Run » Debug 'app' and select the device to run on. It will take some time to get it ready, but there is a progress bar in the footer. When the app launch on the device, a modal will say: “Waiting for the debugger”. Do not force close, just wait, and it will be replaced with the app. You may also activate the app by pressing the “Run app” button in Android Studio.

To stop the running app click on the “Stop” icon in the “app” menubar on the top right (it looks like a square) or press [Ctrl]+[F2].

Adding a button

Final word


Last update: 2019-04-07 [gh].