প্রথম Android অ্যাপ (Hello World) তৈরি করার ধাপে ধাপে গাইড
এই উদাহরণটি দেখায় কিভাবে Android Studio-তে একটি বেসিক "Hello World" অ্যাপ্লিকেশন তৈরি করা যায়।
ধাপ ১: নতুন প্রজেক্ট তৈরি করুন
Android Studio-তে File → New Project এ যান। "Empty Activity" সিলেক্ট করুন। প্রজেক্ট নাম, প্যাকেজ নাম, সেভ লোকেশন, ভাষা (Java/Kotlin) এবং Minimum SDK সিলেক্ট করে Finish করুন।
ধাপ ২: লেআউট XML (activity_main.xml)
res/layout/activity_main.xml ফাইলে ডিফল্ট কোডটি থাকবে। নিচের কোডটি রেফারেন্স হিসেবে দেওয়া হলো:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:app="https://schemas.android.com/apk/res-auto"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
ধাপ ৩: MainActivity.java (বা .kt)
src/MainActivity.java ফাইলে নিচের কোডটি থাকবে:
package com.example.helloworld;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
ধাপ ৪: AndroidManifest.xml
app/manifests/AndroidManifest.xml ফাইলে নিচের কোডটি থাকবে:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
package="com.example.helloworld">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
অ্যাপ্লিকেশন চালানোর পদ্ধতি
আপনার Android ডিভাইস কম্পিউটারের সাথে USB ডিবাগিং অন করে সংযুক্ত করুন। অথবা Emulator তৈরি করুন। Android Studio-তে টুলবারের Run (▶) আইকনে ক্লিক করুন। ডিভাইস সিলেক্ট করুন এবং OK চাপুন। কিছুক্ষণ পর ডিভাইসে "Hello World!" লেখাটি দেখতে পাবেন।

