How to Create a New Test Project in Android Studio

In this section we will learn how to create a simple test project which will print "Hello World!". Before creating a test project in android studio make sure that you have set-up your Android development environment properly as explained in Android studio Set-up tutorial.

To create and deploy a sucessful project we have to follow these three step given below.

  1. Create Your Project
  2. Code Your Project
  3. Run Your Project

1. Create Your Project

In the first step we will create our project to follow some simple step given below.

  • Open android studio and click on New Project.
  • Select the Basic Activity option and click Next to proceed further.
  • On the next screen, type in the name of your app, Project location, Package name of application, Language (Java or Kotlin) and Minimum SDK for your app. The Minimum SDK defines the minimum Android version needed to run your test app..
  • Create Android Project
  • Once the all process done, click on Finish to generate a new test project.

2. Code Your Project

In this section we will code our project. It is optional for us, by defaule our IDE create a default basic code for us.

The first test project takes around 5-10 minutes to load all the files and sync the project using Gradle (a build automation tool). Once it is done, now we can interact with our app's project structure and view different activities in Android Studio.

Any Android App is completely based on MVC Pattern, under which Visual logics of the application completely separate to Logic part and data storage part, so that all three can be developed and maintained independently.

In MVC pattern Visual Part related to View, Logical part related to Controller and the Data Storage are represented by the name of Model

In android app whenever any activity file is created then always by default two file is created.

  • .java file related to controlling Activity such as MainActivity.java
  • .xml file representing the visual part of the activity such as activity_main.xml

The Main Activity File

When we create new Android App, by default MainActivity.java File is created, the following codes are written in it:

Main Activity in Android

The Layout File

The way the Controller File named MainActivity.java is automatically created, in the same way the View / Layout File named activity_main.xml is also automatically created. This file is stored on the "/res/layout/" path of our Android App.

For your "Hello World!" application, this file will have following content related to default layout.

activity main demo

3. Run our Project

Before running your project make sure that you have setup your ADV. Open one of your project's activity files and click Run Icon icon from the tool.

Now we will run and see the result of our project with the help of android emulator.

android emulator