Android KTX

Android KTX, Android Jetpack लाइब्रेरी के लिए Kotlin एक्सटेंशन मॉड्यूल का एक सेट था. हर मॉड्यूल में -ktx सफ़िक्स होता था. उदाहरण के लिए, androidx.core:core-ktx या androidx.fragment:fragment-ktx. इन मॉड्यूल ने बेस लाइब्रेरी में एक्सटेंशन फ़ंक्शन, कोरूटीन सपोर्ट, और Kotlin की अन्य सुविधाएं जोड़ीं.

AndroidX लाइब्रेरी, Kotlin-फ़र्स्ट हैं. साथ ही, KTX एक्सटेंशन हर लाइब्रेरी के बेस मॉड्यूल में शामिल किए जा रहे हैं. ज़्यादातर लाइब्रेरी के लिए, -ktx आर्टफ़ैक्ट खाली होते हैं. ऐसा स्टेबल रिलीज़ वाली लाइब्रेरी के वर्शन से शुरू होता है. आपको इनकी ज़रूरत नहीं होती.

KTX डिपेंडेंसी हटाना

स्टेबल रिलीज़ वाली लाइब्रेरी में मौजूद किसी लाइब्रेरी के लिए, KTX डिपेंडेंसी हटाने के लिए, यह तरीका अपनाएं:

  1. स्टेबल रिलीज़ वाली लाइब्रेरी टेबल में लाइब्रेरी ढूंढें.
  2. पक्का करें कि आपका प्रोजेक्ट, टेबल में दिए गए वर्शन या उसके बाद के वर्शन पर बेस आर्टफ़ैक्ट का इस्तेमाल करता हो.
  3. -ktx आर्टफ़ैक्ट को टेबल में दिए गए बेस आर्टफ़ैक्ट से बदलें. उदाहरण के लिए, androidx.fragment:fragment-ktx को androidx.fragment:fragment से बदलें और androidx.room:room-ktx को androidx.room:room-runtime से बदलें.

आपको अपने कोड या इंपोर्ट में बदलाव करने की ज़रूरत नहीं है. एक्सटेंशन के पैकेज के नाम एक जैसे रहते हैं.

स्टेबल रिलीज़ वाली लाइब्रेरी

इन लाइब्रेरी के लिए, बेस आर्टफ़ैक्ट में स्टेबल रिलीज़ के एक्सटेंशन शामिल होते हैं. -ktx डिपेंडेंसी को हटाया जा सकता है.

KTX आर्टफ़ैक्ट बेस आर्टफ़ैक्ट Empty starting in version
androidx.activity:activity-ktxandroidx.activity:activity1.9.0
androidx.collection:collection-ktxandroidx.collection:collection1.3.0
androidx.core:core-ktxandroidx.core:core1.19.0
androidx.fragment:fragment-ktxandroidx.fragment:fragment1.9.0
androidx.lifecycle:lifecycle-livedata-ktxandroidx.lifecycle:lifecycle-livedata2.7.0
androidx.lifecycle:lifecycle-livedata-core-ktxandroidx.lifecycle:lifecycle-livedata-core2.8.0
androidx.lifecycle:lifecycle-reactivestreams-ktxandroidx.lifecycle:lifecycle-reactivestreams2.6.0
androidx.lifecycle:lifecycle-runtime-ktxandroidx.lifecycle:lifecycle-runtime2.8.0
androidx.lifecycle:lifecycle-viewmodel-ktxandroidx.lifecycle:lifecycle-viewmodel2.8.0
androidx.navigation:navigation-fragment-ktxandroidx.navigation:navigation-fragment2.4.0
androidx.navigation:navigation-runtime-ktxandroidx.navigation:navigation-runtime2.4.0
androidx.navigation:navigation-ui-ktxandroidx.navigation:navigation-ui2.4.0
androidx.paging:paging-common-ktxandroidx.paging:paging-common3.0.0
androidx.paging:paging-runtime-ktxandroidx.paging:paging-runtime3.0.0
androidx.paging:paging-rxjava2-ktxandroidx.paging:paging-rxjava23.0.0
androidx.palette:palette-ktxandroidx.palette:palette1.1.0
androidx.room:room-ktxandroidx.room:room-runtime2.7.0
androidx.savedstate:savedstate-ktxandroidx.savedstate:savedstate1.3.0
androidx.sqlite:sqlite-ktxandroidx.sqlite:sqlite2.7.0
androidx.tracing:tracing-ktxandroidx.tracing:tracing1.3.0
androidx.work:work-runtime-ktxandroidx.work:work-runtime2.9.0

स्टेबल रिलीज़ के बिना लाइब्रेरी

इन लाइब्रेरी के लिए, बेस आर्टफ़ैक्ट में स्टेबल रिलीज़ में KTX एक्सटेंशन शामिल नहीं होते. -ktx डिपेंडेंसी को तब तक बनाए रखें, जब तक कि स्टेबल रिलीज़ में उन्हें शामिल न कर लिया जाए.

KTX आर्टफ़ैक्ट बेस आर्टफ़ैक्ट
androidx.concurrent:concurrent-futures-ktxandroidx.concurrent:concurrent-futures
androidx.dynamicanimation:dynamicanimation-ktxandroidx.dynamicanimation:dynamicanimation
androidx.preference:preference-ktxandroidx.preference:preference
androidx.transition:transition-ktxandroidx.transition:transition
androidx.wear.watchface:watchface-complications-data-source-ktxandroidx.wear.watchface:watchface-complications-data-source

ऐसी लाइब्रेरी जिन्हें बेस मॉड्यूल में नहीं ले जाया जाता

androidx.appsearch:appsearch-ktx आर्टफ़ैक्ट के सभी वर्शन खाली हैं. इसे हटाया जा सकता है.

androidx.security:security-crypto लाइब्रेरी में मौजूद सभी सार्वजनिक एपीआई और इसके KTX मॉड्यूल को अब इस्तेमाल नहीं किया जा सकता. KTX एक्सटेंशन, बेस मॉड्यूल में नहीं जाते. अपने प्रोजेक्ट से लाइब्रेरी हटाएं.