Build Now
Home About Documentation Features Contact Build Now

How to Convert Website to Android App in Android Studio Easy Steps

This guide explains how to create an Android app using Kotlin in Android Studio. It includes setting up the project, folder structure, adding a splash screen, UI, dependencies, and running the app.

Why Use Kotlin for Android Development

  • Concise and readable code
  • Safer with reduced null pointer exceptions
  • Interoperable with Java
  • Modern features like coroutines for background tasks
  • Officially recommended by Google

Step 1: Install and Set Up Android Studio

  1. Download and install Android Studio from the official website.
  2. Launch Android Studio and complete the setup.
  3. Install necessary SDKs when prompted.

Step 2: Create a New Android Project

  1. Open Android Studio and click “Start a new Android Studio project.”
  2. Select “Empty Activity” and click “Next.”
  3. Configure the project:
    • App Name: MyFirstApp
    • Package Name: com.example.myfirstapp
    • Save Location: Choose a folder
    • Language: Kotlin
    • Minimum SDK: API 23 (Android 6.0)
  4. Click “Finish.”

Step 3: Create the AndroidManifest.xml File

Located at app/src/main/AndroidManifest.xml. If missing, create it manually

  1. Update AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myfirstapp">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="My First App"
        android:theme="@style/Theme.MyFirstApp">
        <activity android:name=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity" />
    </application>
</manifest>

Step 4: Implement a Splash Screen

  1. Right-click on java/com/example/myfirstapp/.
  2. Select “New > Kotlin Class/File.”
  3. Name it SplashActivity.
  4. Add the following code.
  1. Update SplashActivity.kt:
package com.example.myfirstapp
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
class SplashActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
        Handler(Looper.getMainLooper()).postDelayed({
            startActivity(Intent(this, MainActivity::class.java))
            finish()
        }, 2000)
    }
}

Step 5: Create the Splash Screen Layout

  1. Navigate to res/layout/.
  2. If activity_splash.xml is missing, right-click on layout/ → “New > Layout Resource File.”
  3. Name it activity_splash.xml.
  4. Add the following XML code.
  1. Update activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@color/white">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher"/>
</LinearLayout>

Step 6: Implement MainActivity.kt

  1. Right-click on java/com/example/myfirstapp/.
  2. Select “New > Kotlin Class/File.”
  3. Name it MainActivity.
  4. Add the following Kotlin code.
  1. Create MainActivity.kt:
package com.example.myfirstapp
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val textView = findViewById<TextView>(R.id.textView)
        val button = findViewById<Button>(R.id.button)
        button.setOnClickListener {
            textView.text = "Button Clicked!"
            Toast.makeText(this, "Button Clicked!", Toast.LENGTH_SHORT).show()
        }
    }
}

Step 7: Set the App Icon

  1. Prepare a 512×512 PNG image.
  2. In Android Studio, right-click res/mipmap/ → “New > Image Asset.”
  3. Select the image and set it as the app launcher icon.
  4. Click “Next > Finish.”

Step 8: Add Dependencies

  1. Open build.gradle (Module: app).
  2. Add the following inside dependencies {}.
  1. Update build.gradle (Module: app) dependencies:
dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
}
  1. Click “Sync Now” to apply changes.

Step 9: Run the App

  1. Open Device Manager.
  2. Create a new virtual device or connect a physical phone via USB.
  3. Click “Run” to launch the app.

Step 10: Build and Export the APK

  1. Click “Build > Build Bundle(s) / APK(s) > Build APK(s).”
  2. Wait for the build process to complete.
  3. Click “Locate APK” to find the generated .apk file.
  4. Transfer and install the .apk on your phone.

Leave a Reply

Your email address will not be published. Required fields are marked *