Android Studio-এ JAR ফাইল লাইব্রেরি হিসেবে যোগ করা
এই টিউটোরিয়ালটি দেখায় কিভাবে একটি বাহ্যিক JAR ফাইল আপনার Android প্রজেক্টে লাইব্রেরি হিসেবে যোগ করতে হয়।
ধাপ ১: নতুন প্রজেক্ট তৈরি করুন
Android Studio-তে File → New Project এ যান এবং একটি নতুন প্রজেক্ট তৈরি করুন।
ধাপ ২: JAR ফাইল libs ফোল্ডারে রাখুন
আপনার প্রজেক্টের Project/app/libs/ ফোল্ডারে JAR ফাইলটি কপি করুন। (যদি libs ফোল্ডার না থাকে, তবে তৈরি করুন।)

ধাপ ৩: ডিপেন্ডেন্সি যোগ করুন (Project Structure 통해서)
- File → Project Structure এ যান।
- বাম প্যানেল থেকে Dependencies ট্যাব নির্বাচন করুন।
- + বাটনে ক্লিক করে JAR Dependency বেছে নিন।
libsফোল্ডার থেকে আপনার JAR ফাইলটি সিলেক্ট করুন এবং OK দিন।


বিকল্প পদ্ধতি (build.gradle ব্যবহার করে):
build.gradle (Module: app) ফাইলে dependencies ব্লকে নিচের লাইনটি যোগ করুন:
dependencies {
implementation files('libs/your-library-name.jar')
}
এরপর Sync Now ক্লিক করুন।
ধাপ ৪: লেআউট 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
package com.app.sample;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// এখানে আপনার JAR লাইব্রেরির ক্লাসগুলো ব্যবহার করতে পারবেন
}
}
ধাপ ৬: AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
package="com.app.sample">
<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>
অ্যাপটি চালান
ডিভাইস সংযুক্ত করে Run ক্লিক করুন। অ্যাপটি সফলভাবে বিল্ড হবে এবং JAR লাইব্রেরি ব্যবহার করতে পারবে।
