Skip to main content

Python type() Function

When learning Python, you will work with different types of data, such as numbers, text, decimal values, and Boolean values. Python provides several built-in functions to help you work with these data types. One of the most useful functions is the type() function . The type() function tells you the data type of a value or variable. It helps you understand what kind of data Python is working with and can make debugging your programs easier. For example, consider these variables: age = 20 price = 99.50 name = "Rahul" is_student = True Although all four variables store data, their data types are different. Python allows us to check these types using type() . Let's understand how it works with simple examples. 1. What Is the type() Function in Python? The type() function is a built-in Python function that returns information about the type of an object. In beginner-level programming, you can use it to check whether a value is an integer, a floating-point number, a string,...

Your First Android App Comes to Life: Creating and Running a Project in Android Studio

In the previous article, we installed and prepared Android Studio, the main development environment for Android application development.

Now it is time to take the next step.

In this tutorial, we will create our first Android project, understand the important options shown during project creation, explore the automatically generated project structure, and run the application for the first time.

You don't need to build anything complicated yet.

Our goal is simple:

Create an Android application and successfully run it.

Once you accomplish this, you will have officially created your first Android app.


What We Are Going to Build

For this first project, we will create a very simple application.

The application will display a basic message on the screen.

Our development process will look like this:

Open Android Studio
       ↓
Create New Project
       ↓
Configure Project
       ↓
Android Studio Generates Files
       ↓
Build Project
       ↓
Run Application
       ↓
First Android App

This may seem simple, but understanding this workflow is extremely important because almost every Android project begins with these basic steps.


Step 1: Open Android Studio

Launch Android Studio on your computer.

After Android Studio starts, you should see the welcome screen.

Depending on your Android Studio version, the interface may look slightly different, but you should find an option similar to:

New Project

Click on New Project.

This will open the project template selection screen.


Step 2: Select a Project Template

Android Studio provides different templates to help developers create applications quickly.

For our first application, select a basic phone and tablet application template.

In modern Android Studio versions, a template such as Empty Activity is commonly used for a simple Jetpack Compose application.

The exact template names and available options may change as Android Studio evolves.

For this series, we will primarily use modern Android development with Kotlin and Jetpack Compose.

After selecting the appropriate template, click:

Next


Step 3: Enter the Application Name

You will now see several project configuration options.

The first important field is usually the application name.

For this tutorial, enter:

MyFirstApp

You can choose a different name if you prefer.

The application name is the name associated with your project and can also become the name users see for the application.

For example:

MyFirstApp

could appear on the device as:

My First App

depending on the application's configured label.


Step 4: Understand the Package Name

You will also encounter an option called the Package name or application package identifier.

For example:

com.example.myfirstapp

A package name uniquely identifies an Android application within the Android ecosystem.

A common structure is:

com.companyname.appname

For example:

com.mycompany.calculator

or:

com.example.myfirstapp

For learning purposes, the default package name generated by Android Studio is fine.

When you eventually publish a real application, you should choose an appropriate unique application identifier.


Step 5: Choose the Project Location

Android Studio will ask where you want to save the project.

Choose a location that is easy to find and has sufficient storage.

For example:

Documents
   └── AndroidProjects
          └── MyFirstApp

Avoid placing projects in locations where you may accidentally delete or move important files.

Keeping all Android projects inside a dedicated folder can make project management easier.


Step 6: Select Kotlin

Modern Android development in this series will use Kotlin.

If Android Studio displays a programming language option, select:

Kotlin

Kotlin is Google's preferred language for modern Android development.

If you already know Java, you will notice that many programming concepts are similar.

If Kotlin is new to you, don't worry.

We will learn the important Kotlin concepts throughout the series.


Step 7: Select the Minimum Android Version

Another important option you may encounter is the Minimum SDK.

The Minimum SDK determines the oldest Android version your application is designed to support.

For example:

Minimum SDK
      ↓
Oldest Android version supported

Choosing a lower minimum version can allow your application to run on more older devices.

However, supporting older Android versions can sometimes introduce additional limitations.

For learning purposes, you can generally use the recommended option provided by Android Studio unless the tutorial specifies otherwise.


Step 8: Create the Project

Once you have configured the project, click:

Finish

Android Studio will now create your project.

You may see messages such as:

Loading...
Indexing...
Gradle Sync...
Building...

Don't be concerned if this takes some time during the first project setup.

Android Studio may need to download dependencies and prepare the project.


What Happens When You Create a Project?

This is an important question.

When you click Finish, Android Studio doesn't simply create one Kotlin file.

It generates an entire Android project.

A simplified structure looks something like this:

MyFirstApp
│
├── app
│   ├── manifests
│   ├── kotlin
│   └── res
│
├── Gradle Scripts
└── Other Project Files

The exact structure and file names can vary between Android Studio versions and project templates.

We will explore the most important parts one by one.


Understanding the app Module

One of the most important parts of your project is the:

app

module.

This contains the main source code and resources for your Android application.

Think of it as the main application module.

Inside it, you will find several important areas.


The AndroidManifest File

One important file is:

AndroidManifest.xml

The Android Manifest provides essential information about your application to the Android operating system.

It can contain information related to:

  • Application configuration

  • Application components

  • Permissions

  • Services

  • Activities

  • Other application metadata

For example, an application that requires internet access may need an appropriate permission depending on how it is designed.

The Manifest is an important part of Android development, and we will study it in more detail later.


The Kotlin Source Code

Your application's Kotlin source code is stored inside the project's source directories.

For a modern Compose-based application, you may find a Kotlin file such as:

MainActivity.kt

This is one of the first files you will work with.

It contains Kotlin code that helps start the application's main screen.


What Is MainActivity?

You may have heard the word Activity before.

An Activity represents a user-facing screen or entry point into an Android application.

For example, an application might contain screens such as:

LoginActivity
HomeActivity
ProfileActivity
SettingsActivity

Modern Android applications can use different navigation architectures and components, so thinking of every screen as a separate Activity is not always accurate.

For now, simply remember that an Activity is an important Android component associated with a user-facing part of an application.


Your First Kotlin Android Code

A newly created Compose project may contain code conceptually similar to:

class MainActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            // User interface
        }
    }
}

Don't worry if you don't understand every line yet.

Let's break down the important parts.


class MainActivity

class MainActivity : ComponentActivity()

This creates a class named:

MainActivity

It extends ComponentActivity, which provides functionality required for this type of Android application.

We will learn about classes and inheritance in detail when we study Kotlin.


onCreate()

You may see:

override fun onCreate(...)

The onCreate() method is called when the Activity is being created.

It is one of the most important lifecycle methods of an Activity.

We will later study the Android Activity lifecycle in detail.


setContent

In a Jetpack Compose application, you will commonly see:

setContent {
    ...
}

This is where the Compose user interface is defined.

For example:

setContent {
    Text("Hello Android!")
}

This tells Compose to display a text element.


Step 9: Build Your First Application

Before running the application, Android Studio needs to build it.

Building an Android project involves processes such as:

Source Code
    ↓
Compile
    ↓
Resolve Dependencies
    ↓
Package
    ↓
Application

You can use the build options provided by Android Studio to check whether your project compiles successfully.

If there are no errors, you're ready to run it.


Step 10: Choose a Device

To run your application, you need an Android device.

You generally have two options:

Option 1 — Android Emulator

Use a virtual Android device running on your computer.

Option 2 — Physical Android Phone

Connect an Android phone configured for development.

If you already created an emulator in the previous setup article, select it from the device selector in Android Studio.

For example, you may see something similar to:

Pixel Device

The exact device names depend on the virtual device you created.


Step 11: Run the Application

Once your device is selected, click the Run button in Android Studio.

Android Studio will:

  1. Build the application.

  2. Install it on the selected device.

  3. Start the application.

  4. Display the application interface.

If everything works correctly, you should see your first Android application running.

Congratulations!

You have created your first Android application.


What Happens Behind the Scenes?

When you click Run, several things happen.

A simplified process looks like this:

You click Run
      ↓
Android Studio starts build
      ↓
Gradle processes the project
      ↓
Kotlin code is compiled
      ↓
Application is packaged
      ↓
App is installed
      ↓
Android launches the app

You don't need to manually perform each of these operations.

Android Studio and the Android build system handle them for you.


Change the Text on the Screen

Now let's make a small modification.

Find the part of your Compose code responsible for displaying the default greeting.

You may see code resembling:

Text(
    text = "Hello Android!"
)

Change it to:

Text(
    text = "Welcome to My Android App!"
)

Run the application again.

You should now see:

Welcome to My Android App!

This is your first small modification to an Android user interface.


A Simple Example

Your application can contain a composable function like:

@Composable
fun Greeting() {
    Text(
        text = "Welcome to Android Development!"
    )
}

The @Composable annotation indicates that the function can be used to describe UI in Jetpack Compose.

Later, you will learn how to create much more sophisticated interfaces using composable functions.


What Is a Composable Function?

Jetpack Compose introduces an important concept called a Composable function.

A composable function is a Kotlin function that describes part of your application's user interface.

For example:

@Composable
fun WelcomeMessage() {
    Text("Hello Android!")
}

You can think of it as a reusable UI building block.

For example:

Application
│
├── Top Bar
├── Welcome Message
├── Image
├── Button
└── Footer

Each section can potentially be represented using composable functions.

This makes it easier to organize larger interfaces.


Understanding Resources

Android applications can contain resources such as:

  • Images

  • Icons

  • Strings

  • Colors

  • Fonts

  • Other configuration resources

Traditionally, these are often organized under the res directory.

Even though Jetpack Compose allows much of the UI to be written directly in Kotlin, Android resource management remains an important concept.

We will learn how to work with resources later.


What If the App Doesn't Run?

Don't worry.

Errors are normal in software development.

If your application doesn't run, check the error message.

Common problems include:

Gradle Sync Error

Your project may not have successfully synchronized its dependencies.

SDK Problem

A required Android SDK component may be missing.

Emulator Problem

The virtual device may not have started correctly.

Compilation Error

There may be an error in the Kotlin code.

Insufficient Resources

Your computer may not have enough available RAM or storage.

The important rule is:

Don't randomly change settings when you encounter an error. First understand what the error is telling you.


Your First Android Development Workflow

You have now experienced the basic workflow that you will use repeatedly.

Create Project
      ↓
Write Code
      ↓
Build
      ↓
Run
      ↓
Test
      ↓
Find Errors
      ↓
Fix Errors
      ↓
Run Again

This cycle is at the heart of software development.

As your applications become larger, the process will become more sophisticated, but the basic idea remains the same.


Practice Exercise

Before moving to the next article, try making a few changes to your application.

Exercise 1

Change:

Hello Android!

to:

My First Android Application

Exercise 2

Change the message again to:

I am learning Android development.

Exercise 3

Try creating another composable function.

For example:

@Composable
fun DeveloperName() {
    Text("Android Developer")
}

Then experiment with displaying it in your application.

Don't worry if you make mistakes.

Experimenting is one of the best ways to learn programming.


What You Learned Today

In this article, you learned how to:

  • Open Android Studio

  • Create a new Android project

  • Select a project template

  • Choose Kotlin

  • Understand the application name

  • Understand the package name

  • Choose a project location

  • Understand the Minimum SDK

  • Understand the basic project structure

  • Locate Kotlin source code

  • Understand MainActivity

  • Understand onCreate()

  • Understand setContent

  • Create a simple Compose UI

  • Build an Android application

  • Run an application on a device

Most importantly, you created and ran your first Android application.


What's Coming Next?

We have successfully created our first application, but we still have a lot to learn.

In the next article, we will step back for a moment and learn an essential foundation:

Kotlin programming fundamentals.

Before creating complex Android applications, you need to understand the programming language used to build them.

We will start with:

  • Variables

  • Data types

  • val and var

  • Strings

  • Numbers

  • Boolean values

  • Basic operators

  • Simple Kotlin programs

Once these fundamentals are clear, we will gradually return to Android development and use Kotlin to create real application features.


Final Words

Creating your first Android application is a small achievement, but it is an important milestone.

You have now gone from:

"I want to learn Android development"

to:

"I have created and run an Android application."

From this point onward, the focus will shift from simply running an application to understanding how to build one.

Keep experimenting with your project, change the text, break things, fix them, and become comfortable inside Android Studio.

The more you practice, the more natural Android development will become.

Comments

Popular posts from this blog

Understanding Comments in Java: A Beginner’s Guide

When learning Java programming, one of the first concepts you’ll come across is comments . Comments may not affect how a program runs, but they play a crucial role in making code more understandable, readable, and maintainable. Let’s dive deeper into what comments are, why they’re important, and the different types of comments in Java. What are Comments in Java? A comment in Java is a piece of text written within a program that is ignored by the compiler . In other words, comments are notes for humans, not instructions for machines. They help developers explain the purpose of code, describe logic, or temporarily disable certain lines of code without deleting them. Why are Comments Important? 📌 Readability – Comments make code easier to understand for you and others. 📌 Maintenance – When you revisit your code after months, comments remind you what you were doing. 📌 Collaboration – In team projects, comments explain code to fellow developers. 📌 Debugging – You c...

Java Program to Check Voting Eligibility

In this program, we’ll take the user’s age as input and check whether the person is eligible to vote or not. In India, the minimum age required to vote is 18 years . 💻 Program Code // Java Program to Check Voting Eligibility import java.util.Scanner; public class VotingEligibility { public static void main(String[] args) { // Create Scanner object to take input from user Scanner sc = new Scanner(System.in); // Ask user to enter age System.out.print("Enter your age: "); int age = sc.nextInt(); // Check eligibility if (age >= 18) { System.out.println("You are eligible to vote."); } else { System.out.println("You are not eligible to vote yet."); System.out.println("You can vote after " + (18 - age) + " year(s)."); } sc.close(); // Close the scanner } } 🧠 Explanation import java.util.Scanner; → Imp...

Java Program to Calculate Total Marks and Average of Five Subjects

💡 Program Explanation In this program: The user will input marks of five subjects . The program will calculate the total marks and average . It will then display both results clearly. 🧑‍💻 Java Code: // Java Program to Calculate Total Marks and Average of Five Subjects import java.util.Scanner; // Importing Scanner class for user input public class TotalAndAverage { public static void main(String[] args) { // Creating Scanner object to take input from user Scanner sc = new Scanner(System.in); // Declaring variables for five subjects double subject1, subject2, subject3, subject4, subject5; // Taking marks input for each subject System.out.print("Enter marks of Subject 1: "); subject1 = sc.nextDouble(); System.out.print("Enter marks of Subject 2: "); subject2 = sc.nextDouble(); System.out.print("Enter marks of Subject 3: "); subject3 = sc.nextDo...