For creating the simple example:

  1. Create the new android project
  2. Write the message (optional)
  3. Run the android application

You need to follow the 3 steps mentioned above for creating the Hello android application.

1) Create the New Android project

For creating the new android studio project:

1) Select Start a new Android Studio project

2) Provide the following information: Application name, Company domain, Project location and Package name of application and click next.

3) Select the API level of the application and click next.

4) Select the Activity type (Empty Activity).

5) Provide the Activity Name and click finish.

After finishing the Activity configuration, Android Studio auto generates the activity class and other required configuration files.

Now an android project has been created. You can explore the android project and see the simple program, it looks like this:

2) Write the message

File: activity_main.xml

Android studio auto generates code for activity_main.xml file. You may edit this file according to your requirement.

<?xml version=”1.0″ encoding=”utf-8″?>  

<android.support.constraint.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android”  

    xmlns:app=”http://schemas.android.com/apk/res-auto”  

    xmlns:tools=”http://schemas.android.com/tools”  

    android:layout_width=”match_parent”  

    android:layout_height=”match_parent”  

    tools:context=”first.javatpoint.com.welcome.MainActivity”>  

    <TextView  

        android:layout_width=”wrap_content”  

        android:layout_height=”wrap_content”  

        android:text=”Hello Android!”  

        app:layout_constraintBottom_toBottomOf=”parent”  

        app:layout_constraintLeft_toLeftOf=”parent”  

        app:layout_constraintRight_toRightOf=”parent”  

        app:layout_constraintTop_toTopOf=”parent” />  

</android.support.constraint.ConstraintLayout>  

}  

File: MainActivity.java

package first.javatpoint.com.welcome;  

import android.support.v7.app.AppCompatActivity;  

import android.os.Bundle;  

public class MainActivity extends AppCompatActivity {  

    @Override  

    protected void onCreate(Bundle savedInstanceState) {  

        super.onCreate(savedInstanceState);  

        setContentView(R.layout.activity_main);  

    }  

}  

3) Run the android application

To run the android application, click the run icon on the toolbar or simply press Shift + F10.

The android emulator might take 2 or 3 minutes to boot. So please have patience. After booting the emulator, the android studio install the application and launches the activity. You will see something like this: