সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
লাইব্রেরি মডিউল কনফিগার করার জন্য কোটলিন মাল্টিপ্ল্যাটফর্মের একটি গ্রেডল প্লাগইন রয়েছে।
com.android.kotlin.multiplatform.library প্লাগইন হল নিয়মিত অ্যান্ড্রয়েড লাইব্রেরি গ্রেডল প্লাগইন ( com.android.library ) ব্যবহার করে KMP লাইব্রেরিতে Android টার্গেট যোগ করার আগের পদ্ধতির অফিসিয়াল প্রতিস্থাপন।
পূর্ববর্তী পদ্ধতিটি এখন প্লাগইনের পক্ষে অবহেলিত হয়েছে, এটিকে Android-KMP প্লাগইনও বলা হয়। KMP-এর জন্য com.android.library প্লাগইন ব্যবহার চালিয়ে যাওয়া জেটব্রেইন দ্বারা আর সমর্থিত হবে না এবং ভবিষ্যতের আপডেট এবং উন্নতি থেকে উপকৃত হবে না।
অ্যান্ড্রয়েড-কেএমপি প্লাগইনটি বিশেষভাবে কেএমপি প্রজেক্টের জন্য তৈরি করা হয়েছে এবং বিভিন্ন মূল দিকগুলিতে স্ট্যান্ডার্ড com.android.library প্লাগইন থেকে আলাদা:
একক ভেরিয়েন্ট আর্কিটেকচার: প্লাগইনটি একটি একক বৈকল্পিক ব্যবহার করে, পণ্যের স্বাদ এবং বিল্ড প্রকারের জন্য সমর্থন অপসারণ করে, যা কনফিগারেশনকে সহজ করে এবং বিল্ড কর্মক্ষমতা বাড়ায়।
কেএমপির জন্য অপ্টিমাইজ করা হয়েছে: প্লাগইনটি কেএমপি লাইব্রেরির জন্য ডিজাইন করা হয়েছে, শেয়ার্ড কোটলিন কোড এবং ইন্টারঅপারেবিলিটির উপর ফোকাস করে, অ্যান্ড্রয়েড-নির্দিষ্ট নেটিভ বিল্ড, AIDL এবং রেন্ডারস্ক্রিপ্টের জন্য সমর্থন বাদ দিয়ে।
ডিফল্টরূপে পরীক্ষা নিষ্ক্রিয়: ইউনিট এবং ডিভাইস (ইনস্ট্রুমেন্টেশন) উভয় পরীক্ষাই ডিফল্টরূপে বিল্ড গতি বাড়ানোর জন্য নিষ্ক্রিয় করা হয়। প্রয়োজনে আপনি তাদের সক্ষম করতে পারেন।
কোন টপ-লেভেল অ্যান্ড্রয়েড এক্সটেনশন নেই: একটি সামঞ্জস্যপূর্ণ কেএমপি প্রকল্প কাঠামো বজায় রেখে গ্রেডল কেএমপি ডিএসএল-এর মধ্যে একটি androidLibrary ব্লকের সাথে কনফিগারেশন পরিচালনা করা হয়। কোনো শীর্ষ-স্তরের android এক্সটেনশন ব্লক নেই।
অপ্ট-ইন জাভা সংকলন: জাভা সংকলন ডিফল্টরূপে অক্ষম করা হয়। এটি সক্রিয় করতে androidLibrary ব্লকে withJava() ব্যবহার করুন। যখন জাভা সংকলনের প্রয়োজন হয় না তখন এটি বিল্ড সময়কে উন্নত করে।
অ্যান্ড্রয়েড-কেএমপি লাইব্রেরি প্লাগইনের সুবিধা
Android-KMP প্লাগইন KMP প্রকল্পগুলির জন্য নিম্নলিখিত সুবিধাগুলি প্রদান করে:
উন্নত বিল্ড পারফরম্যান্স এবং স্থিতিশীলতা: এটি কেএমপি প্রকল্পগুলির মধ্যে অপ্টিমাইজ করা বিল্ড গতি এবং উন্নত স্থিতিশীলতার জন্য ইঞ্জিনিয়ার করা হয়েছে। এটি কেএমপি ওয়ার্কফ্লোগুলির উপর ফোকাস একটি আরও দক্ষ এবং নির্ভরযোগ্য বিল্ড প্রক্রিয়াতে অবদান রাখে।
উন্নত আইডিই ইন্টিগ্রেশন: এটি KMP অ্যান্ড্রয়েড লাইব্রেরিগুলির সাথে কাজ করার সময় আরও ভাল কোড সমাপ্তি, নেভিগেশন, ডিবাগিং এবং সামগ্রিক বিকাশকারী অভিজ্ঞতা প্রদান করে।
সরলীকৃত প্রকল্প কনফিগারেশন: প্লাগইনটি বিল্ড ভেরিয়েন্টের মতো অ্যান্ড্রয়েড-নির্দিষ্ট জটিলতাগুলি সরিয়ে KMP প্রকল্পগুলির জন্য কনফিগারেশনকে সহজ করে। এটি পরিষ্কার এবং আরও রক্ষণাবেক্ষণযোগ্য বিল্ড ফাইলের দিকে নিয়ে যায়। পূর্বে, KMP প্রজেক্টে com.android.library প্লাগইন ব্যবহার করলে বিভ্রান্তিকর উৎস সেট নাম তৈরি হতে পারে, যেমন androidAndroidTest । এই নামকরণ কনভেনশনটি আদর্শ KMP প্রকল্প কাঠামোর সাথে পরিচিত ডেভেলপারদের জন্য কম স্বজ্ঞাত ছিল।
একটি বিদ্যমান মডিউলে Android-KMP প্লাগইন প্রয়োগ করুন
একটি বিদ্যমান KMP লাইব্রেরি মডিউলে Android-KMP প্লাগইন প্রয়োগ করতে, এই পদক্ষেপগুলি অনুসরণ করুন:
সংস্করণ ক্যাটালগে প্লাগইন ঘোষণা করুন। সংস্করণ ক্যাটালগ TOML ফাইলটি খুলুন (সাধারণত gradle/libs.versions.toml ) এবং প্লাগইন সংজ্ঞা বিভাগ যোগ করুন:
# To check the version number of the latest Kotlin release, go to# https://kotlinlang.org/docs/releases.html[versions]androidGradlePlugin="8.12.0"kotlin="KOTLIN_VERSION"[plugins]kotlin-multiplatform={id="org.jetbrains.kotlin.multiplatform",version.ref="kotlin"}android-kotlin-multiplatform-library={id="com.android.kotlin.multiplatform.library",version.ref="androidGradlePlugin"}
রুট বিল্ড ফাইলে প্লাগইন ঘোষণা প্রয়োগ করুন। আপনার প্রকল্পের রুট ডিরেক্টরিতে অবস্থিত build.gradle.kts ফাইলটি খুলুন। apply false ব্যবহার করে plugins ব্লকে প্লাগইন উপনাম যোগ করুন। এটি রুট প্রকল্পে প্লাগইন যুক্তি প্রয়োগ না করেই সমস্ত সাবপ্রকল্পের জন্য প্লাগইন উপনাম উপলব্ধ করে।
কোটলিন
// Root build.gradle.kts fileplugins{alias(libs.plugins.kotlin.multiplatform)applyfalse// Add the followingalias(libs.plugins.android.kotlin.multiplatform.library)applyfalse}
গ্রোভি
// Root build.gradle fileplugins{alias(libs.plugins.kotlin.multiplatform)applyfalse// Add the followingalias(libs.plugins.android.kotlin.multiplatform.library)applyfalse}
একটি KMP লাইব্রেরি মডিউল বিল্ড ফাইলে প্লাগইনটি প্রয়োগ করুন। আপনার KMP লাইব্রেরি মডিউলে build.gradle.kts ফাইলটি খুলুন এবং plugins ব্লকের মধ্যে আপনার ফাইলের শীর্ষে প্লাগইনটি প্রয়োগ করুন:
কোটলিন
// Module-specific build.gradle.kts fileplugins{alias(libs.plugins.kotlin.multiplatform)// Add the followingalias(libs.plugins.android.kotlin.multiplatform.library)}
গ্রোভি
// Module-specific build.gradle fileplugins{alias(libs.plugins.kotlin.multiplatform)// Add the followingalias(libs.plugins.android.kotlin.multiplatform.library)}
Android KMP লক্ষ্য কনফিগার করুন। অ্যান্ড্রয়েড লক্ষ্য নির্ধারণ করতে Kotlin মাল্টিপ্ল্যাটফর্ম ব্লক ( kotlin ) কনফিগার করুন। kotlin ব্লকের মধ্যে, androidLibrary ব্যবহার করে Android লক্ষ্য নির্দিষ্ট করুন:
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-27 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-08-27 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Migrate to the Android-KMP library plugin\n\nKotlin Multiplatform has a Gradle plugin to configure the\n[library module](/studio/projects/android-library).\n\nThe `com.android.kotlin.multiplatform.library` plugin is the official\nreplacement for the previous method of adding Android targets to KMP libraries\nusing the regular Android library Gradle plugin (`com.android.library`).\n\nThe previous approach is now deprecated in favor of the plugin, also referred to\nas the **Android-KMP plugin** . Continuing to use the `com.android.library`\nplugin for KMP will no longer be supported by JetBrains and won't benefit from\nfuture updates and improvements.\n| **Note:** Configuring the Android **application** module using `com.android.application` doesn't change.\n\nTo migrate to this plugin, refer to the [Apply the Android-KMP plugin](#apply)\nsection.\n\nKey features and differences\n----------------------------\n\nThe Android-KMP plugin is tailored specifically for KMP projects and differs\nfrom the standard `com.android.library` plugin in several key aspects:\n\n- **Single variant architecture:** The plugin uses a single variant, removing\n support for product flavors and build types, which simplifies configuration\n and enhances build performance.\n\n- **Optimized for KMP:** The plugin is designed for KMP libraries, focusing on\n shared Kotlin code and interoperability, omitting support for\n Android-specific native builds, AIDL, and RenderScript.\n\n- **Tests disabled by default:** Both unit and device (instrumentation) tests\n are disabled by default to enhance build speed. You can enable them if\n required.\n\n- **No top-Level Android extension:** Configuration is handled with an\n `androidLibrary` block within the Gradle KMP DSL, maintaining a consistent\n KMP project structure. There's no top-level `android` extension block.\n\n- **Opt-in Java compilation:** Java compilation is disabled by default. Use\n `withJava()` in the `androidLibrary` block to enable it. This improves build\n times when Java compilation is not needed.\n\nBenefits of the Android-KMP library plugin\n------------------------------------------\n\nThe Android-KMP plugin provides the following benefits for KMP projects:\n\n- **Improved build performance and stability:** It's engineered for optimized\n build speeds and enhanced stability within KMP projects. It's focus on KMP\n workflows contribute to a more efficient and reliable build process.\n\n- **Enhanced IDE integration:** It provides better code completion,\n navigation, debugging, and overall developer experience when working with\n KMP Android libraries.\n\n- **Simplified project configuration:** The plugin simplifies configuration\n for KMP projects by removing Android-specific complexities like build\n variants. This leads to cleaner and more maintainable build files.\n Previously, using the `com.android.library` plugin in KMP project could\n create confusing source set names, such as `androidAndroidTest`. This naming\n convention was less intuitive for developers familiar with standard KMP\n project structures.\n\nApply the Android-KMP plugin to an existing module\n--------------------------------------------------\n\nTo apply the Android-KMP plugin to an existing KMP library module, follow these\nsteps:\n\n1. **Declare plugins in version catalog.** Open the version catalog TOML file\n (usually `gradle/libs.versions.toml`) and add the plugin definitions\n section:\n\n # To check the version number of the latest Kotlin release, go to\n # https://kotlinlang.org/docs/releases.html\n\n [versions]\n androidGradlePlugin = \"8.12.0\"\n kotlin = \"\u003cvar translate=\"no\"\u003eKOTLIN_VERSION\u003c/var\u003e\"\n\n [plugins]\n kotlin-multiplatform = { id = \"org.jetbrains.kotlin.multiplatform\", version.ref = \"kotlin\" }\n android-kotlin-multiplatform-library = { id = \"com.android.kotlin.multiplatform.library\", version.ref = \"androidGradlePlugin\" }\n\n2. **Apply the plugin declaration in root build file.** Open the\n `build.gradle.kts` file located in the root directory of your project. Add\n the plugin aliases to the `plugins` block using `apply false`. This makes\n the plugin aliases available to all subprojects without applying the plugin\n logic to the root project itself.\n\n ### Kotlin\n\n ```kotlin\n // Root build.gradle.kts file\n\n plugins {\n alias(libs.plugins.kotlin.multiplatform) apply false\n\n // Add the following\n alias(libs.plugins.android.kotlin.multiplatform.library) apply false\n }\n ```\n\n ### Groovy\n\n ```groovy\n // Root build.gradle file\n\n plugins {\n alias(libs.plugins.kotlin.multiplatform) apply false\n\n // Add the following\n alias(libs.plugins.android.kotlin.multiplatform.library) apply false\n }\n ```\n3. **Apply the plugin in a KMP library module build file.** Open the\n `build.gradle.kts` file in your KMP library module and apply the plugin at\n the top of your file within the `plugins` block:\n\n ### Kotlin\n\n ```kotlin\n // Module-specific build.gradle.kts file\n\n plugins {\n alias(libs.plugins.kotlin.multiplatform)\n\n // Add the following\n alias(libs.plugins.android.kotlin.multiplatform.library)\n }\n ```\n\n ### Groovy\n\n ```groovy\n // Module-specific build.gradle file\n\n plugins {\n alias(libs.plugins.kotlin.multiplatform)\n\n // Add the following\n alias(libs.plugins.android.kotlin.multiplatform.library)\n }\n ```\n4. **Configure Android KMP target.** Configure the Kotlin Multiplatform block\n (`kotlin`) to define the Android target. Within the `kotlin` block, specify\n the Android target using `androidLibrary`:\n\n ### Kotlin\n\n ```kotlin\n kotlin {\n androidLibrary {\n namespace = \"com.example.kmpfirstlib\"\n compileSdk = 33\n minSdk = 24\n\n withJava() // enable java compilation support\n withHostTestBuilder {}.configure {}\n withDeviceTestBuilder {\n sourceSetTreeName = \"test\"\n }\n\n compilations.configureEach {\n compilerOptions.configure {\n jvmTarget.set(\n org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8\n )\n }\n }\n }\n\n sourceSets {\n androidMain {\n dependencies {\n // Add Android-specific dependencies here\n }\n }\n getByName(\"androidHostTest\") {\n dependencies {\n }\n }\n\n getByName(\"androidDeviceTest\") {\n dependencies {\n }\n }\n }\n // ... other targets (JVM, iOS, etc.) ...\n }\n ```\n\n ### Groovy\n\n ```groovy\n kotlin {\n androidLibrary {\n namespace = \"com.example.kmpfirstlib\"\n compileSdk = 33\n minSdk = 24\n\n withJava() // enable java compilation support\n withHostTestBuilder {}.configure {}\n withDeviceTestBuilder {\n it.sourceSetTreeName = \"test\"\n }\n\n compilations.configureEach {\n compilerOptions.options.jvmTarget.set(\n org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8\n )\n }\n }\n\n sourceSets {\n androidMain {\n dependencies {\n }\n }\n androidHostTest {\n dependencies {\n }\n }\n androidDeviceTest {\n dependencies {\n }\n }\n }\n // ... other targets (JVM, iOS, etc.) ...\n }\n ```\n5. **Apply changes.** After applying the plugin and configuring the `kotlin`\n block, sync your Gradle project to apply the changes.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Set up your environment](/kotlin/multiplatform/setup)\n- [Add KMP module to a project](/kotlin/multiplatform/migrate)"]]