Bart Kessels
Bart Kessels
Passionate open source software engineer who loves to go backpacking

Create an Android app

Create an Android app
This image is generated using Dall-E
  • Prompt: 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.

    1. Download and install Android Studio
    2. Setup a virtual Android device1
    3. 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

    Set up Jetpack Compose

    In Android development, the new standard for building UI's is Jetpack Compose. But how do you actually set ...

    Set up View Models with Jetpack Compose

    You've just set up Jetpack Compose, but how do you properly separate the UI from the business logic? This i...

    Set up Material Design with Jetpack Compose

    You've just set up Jetpack Compose, and now you want to make your app look like a native Android app. This ...

    Support multiple languages in your app

    The user base for your application includes multiple nationalities, so why don't you update your app to all...

    Enable UI preview in Android Studio

    When developing an Android app, you're likely to iterate through multiple UIs. When going through this proc...

    Automatically testing the UI of your Android app

    During your development phase, you'd like everything that can be automated to be automated. This also goes ...