Create an Android app
This image is generated using Dall-EPrompt: Generate an image of a person sitting behind a computer screen which is displaying a phone on the screen in a minimalistic flat style
Have you ever had the urge to build your own Android app? Well, I have, and in this story I’ll be covering the basics on how you can build an Android app.
The app we’ll be building is just a small hello world application, but it will be using the latest Android technologies. The reason for this simple application is that I can use this story as an accelerator when I want to either build an app or want to test some new features in Android.
Prerequisites
Before we can start building our application, let’s make sure that we have everything we need.
- Download and install Android Studio
- Setup a virtual Android device1
- Some knowledge about the Android lifecycle and Kotlin
1: Skip this step if you have an actual device
Create the project
The project can be created using the wizard in Android Studio where I’ve used the following settings. You can obviously change them to your own needs.
- Template: No Activity
- Name: My Application
- Package name: net.bartkessels.myapplication
- Language: Kotlin
- Minimum SDK: 26 (Oreo)
- Build configuration language: Kotlin DSL
However, changing the template might cause some extra work if you’re going to use Jetpack compose eventually as the template you can choose might include the old school XML-views. This isn’t a big deal, but might take some extra time to remove them.
Project structure
When running the wizard with the previously mentioned settings, your folder structure should look like this (I’ve ignored the Gradle scripts).
One thing that I always change when creating a new project is changing the name of the java
-folder to kotlin
. This isn’t necessary, but I find it cleaner. If you choose to keep the java
-folder, this won’t impact your application. You need to be aware of the fact that the following posts will be referencing the kotlin
-folder.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
- app/
- src/
- androidTest/
- kotlin/
- net.bartkessels.myapplication/
- main/
- kotlin/
- net.bartkessels.myapplication/
- res/
- drawable/
- mipmap-*/
- values/
- values-night/
- xml
- test/
- kotlin/
- net.bartkessels.myapplication/
- build.gradle.kts
- build.gradle.kts
- gradle.properties
- settings.gradle.kts
Running the project
You want to run your project to see what you’ve just created. However, we haven’t created anything as far as Android is aware. So, running your application will result in the Default Activity not found
error message in Android Studio.
Where regular applications rely on a main
method or function, Android requires the use of Activities as an entry point (Google, 2024). And as you see, the No Activity template does not include an activity (just like the name says).
In the following stories we’ll be creating an activity, and you’ll be able to run your own application!
Categories
Related articles