📱 How to Make Your First Android App in Java (Step by Step Guide)
Build Your First
Android App
with Java
If you are a beginner and want to start Android development, this guide is perfect for you. We will build a simple Hello World Android App using Java — step by step, from scratch.
This is just the beginning of your Android journey. Once you build this Hello World app, you'll understand the core structure of every Android project — and from there, the sky is the limit.
First, you need to install Android Studio — the official IDE for Android development.
Download the installer: Go to the official Android Developers website and download the recommended Windows .exe installation file.
Run & follow the setup wizard:
- Double-click the downloaded .exe file. Click "Yes" if prompted by User Account Control.
- Click Next on the Welcome screen.
- On the Choose Components screen, keep both Android Studio and Android Virtual Device (AVD) checked.
- Accept the default installation location, then click Next → Install.
- Leave "Start Android Studio" selected and click Finish.
Complete the initial setup: Android Studio will launch the Setup Wizard to download SDK components. Choose Standard installation, select your preferred UI theme (Light or Darcula), agree to the license agreements, and click Finish to start the download.
Once Android Studio is ready, follow these steps:
- Open Android Studio
- Click New Project
- Select Empty Activity → Click Next
Now fill in the project details:
Project Name → MyFirstApp Language → Java Min SDK → API 21 (Android 5.0) Package Name → com.example.myfirstapp
Click Finish and wait for the project to load. Gradle sync may take a minute.
After creating the project, you will see two important files in the left panel:
Every Android app follows this structure. The Java file controls behavior, the XML file controls the visual layout.
Open activity_main.xml and replace the existing code with the following:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" android:textSize="24sp" android:layout_gravity="center" /> </FrameLayout>
The TextView widget displays text on the screen. We set it to center and give it a size of 24sp.
Open MainActivity.java. The default generated code is already correct — make sure it looks like this:
package com.example.myfirstapp; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This line connects MainActivity to activity_main.xml setContentView(R.layout.activity_main); } }
The onCreate() method runs when the app starts. The setContentView() line loads your XML layout onto the screen.
Now it's time to run your app and see it in action!
- Open Device Manager from the toolbar and create a virtual device (emulator)
- Click the green Run ▶ button (or press
Shift + F10) - Wait for the Gradle build to complete — first build may take a few minutes
- Your app will launch on the emulator!
Congratulations!
You have successfully built your first Android app using Java. This is just the beginning — now you can move on to buttons, forms, navigation, and full applications.
Comments
Post a Comment