top of page

Creating Your First Android App in Java: A Step-by-Step Guide

Updated: Mar 14, 2023



Let us start actual programming with Android Framework. Before you start writing your first example using Android SDK, you have to make sure that you have set-up your Android development environment properly as explained in Previous tutorial. I also assume that you have a little bit working knowledge with Android studio.

So let us proceed to write a simple Android Application which will create button "Click Me".


Steps For Creating Your first App -


Install Android Studio: Download and install the latest version of Android Studio from the official website (as told earlier)

Create a new project: Launch Android Studio and select "Create New Project" from the main screen.


Choose activity type: Select "Empty Activity" or any other activity type that suits your app.


Click on NEXT and Enter your application name, package name, and other details as required.


Design the user interface: Open the activity_main.xml file from the "res/layout" folder and design the user interface using drag-and-drop or by editing the XML code. And Copy paste the code given below -


<Button
    android:id="@+id/myButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Click me!"
    tools:ignore="MissingConstraints" />

Your Screen will look as shown below -


Your Design section will look as shown below -


Add functionality to the app: Open the MainActivity.java file and add the required code to implement the app functionality. For example, you can add an onClickListener to a button to perform an action when the button is clicked.


public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button myButton = findViewById(R.id.myButton);
        myButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Perform action when button is clicked
                Toast.makeText(MainActivity.this, "Button clicked!", Toast.LENGTH_SHORT).show();
            }
        });
    }
}

Build and run the app: Click on the "Run" button in Android Studio to build and run the app on an emulator or a physical device. Application will look like this -



Congratulations! you created first app in Java ✨


I hope this step-by-step guide has helped you in creating your first Android app in Java. Remember that this is just the beginning, and there is a lot more to learn about Android app development.

As you continue to learn and explore, be sure to reference the official Android documentation and developer guides, as well as online resources and communities, to expand your knowledge and skills.


Thanks for reading, and happy coding!







bottom of page