জীবনচক্র
এই টেবিলে androidx.lifecycle গ্রুপের সমস্ত শিল্পকর্মের তালিকা দেওয়া আছে।
| শিল্পকর্ম | স্থিতিশীল রিলিজ | রিলিজ প্রার্থী | বিটা রিলিজ | আলফা রিলিজ |
|---|---|---|---|---|
| জীবনচক্র-* | ২.৯.৪ | ২.১০.০-আরসি০১ | - | - |
| জীবনচক্র-ভিউমডেল-নেভিগেশন3 | - | ২.১০.০-আরসি০১ | - | - |
নির্ভরতা ঘোষণা করা
লাইফসাইকেলের উপর নির্ভরতা যোগ করতে, আপনার প্রোজেক্টে গুগল ম্যাভেন রিপোজিটরি যোগ করতে হবে। আরও তথ্যের জন্য গুগলের ম্যাভেন রিপোজিটরি পড়ুন।
আপনার অ্যাপ বা মডিউলের জন্য build.gradle ফাইলে আপনার প্রয়োজনীয় আর্টিফ্যাক্টের জন্য নির্ভরতা যোগ করুন:
কোটলিন
গ্রোভি
dependencies { def lifecycle_version = "2.9.4" def arch_version = "2.2.0" // ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" // ViewModel utilities for Compose implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version" // LiveData implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" // Lifecycles only (without ViewModel or LiveData) implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" // Lifecycle utilities for Compose implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version" // Saved state module for ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" // ViewModel integration with Navigation3 implementation "androidx.lifecycle:lifecycle-viewmodel-navigation3:2.10.0-rc01" // Annotation processor kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // alternately - if using Java8, use the following instead of lifecycle-compiler implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" // optional - helpers for implementing LifecycleOwner in a Service implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version" // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version" // optional - ReactiveStreams support for LiveData implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version" // optional - Test helpers for LiveData testImplementation "androidx.arch.core:core-testing:$arch_version" // optional - Test helpers for Lifecycle runtime testImplementation "androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version" }
কোটলিন
dependencies { val lifecycle_version = "2.9.4" val arch_version = "2.2.0" // ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version") // ViewModel utilities for Compose implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version") // LiveData implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version") // Lifecycles only (without ViewModel or LiveData) implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version") // Lifecycle utilities for Compose implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version") // Saved state module for ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version") // ViewModel integration with Navigation3 implementation("androidx.lifecycle:lifecycle-viewmodel-navigation3:2.10.0-rc01") // Annotation processor kapt("androidx.lifecycle:lifecycle-compiler:$lifecycle_version") // alternately - if using Java8, use the following instead of lifecycle-compiler implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version") // optional - helpers for implementing LifecycleOwner in a Service implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version") // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation("androidx.lifecycle:lifecycle-process:$lifecycle_version") // optional - ReactiveStreams support for LiveData implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version") // optional - Test helpers for LiveData testImplementation("androidx.arch.core:core-testing:$arch_version") // optional - Test helpers for Lifecycle runtime testImplementation ("androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version") }
জাভা
গ্রোভি
dependencies { def lifecycle_version = "2.9.4" def arch_version = "2.2.0" // ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // LiveData implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version" // Lifecycles only (without ViewModel or LiveData) implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version" // Saved state module for ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" // Annotation processor annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // alternately - if using Java8, use the following instead of lifecycle-compiler implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" // optional - helpers for implementing LifecycleOwner in a Service implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version" // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version" // optional - ReactiveStreams support for LiveData implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // optional - Test helpers for LiveData testImplementation "androidx.arch.core:core-testing:$arch_version" // optional - Test helpers for Lifecycle runtime testImplementation "androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version" }
কোটলিন
dependencies { val lifecycle_version = "2.9.4" val arch_version = "2.2.0" // ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version") // LiveData implementation("androidx.lifecycle:lifecycle-livedata:$lifecycle_version") // Lifecycles only (without ViewModel or LiveData) implementation("androidx.lifecycle:lifecycle-runtime:$lifecycle_version") // Saved state module for ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version") // Annotation processor annotationProcessor("androidx.lifecycle:lifecycle-compiler:$lifecycle_version") // alternately - if using Java8, use the following instead of lifecycle-compiler implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version") // optional - helpers for implementing LifecycleOwner in a Service implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version") // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation("androidx.lifecycle:lifecycle-process:$lifecycle_version") // optional - ReactiveStreams support for LiveData implementation("androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version") // optional - Test helpers for LiveData testImplementation("androidx.arch.core:core-testing:$arch_version") // optional - Test helpers for Lifecycle runtime testImplementation("androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version") }
নির্ভরতা সম্পর্কে আরও তথ্যের জন্য, বিল্ড নির্ভরতা যোগ করুন দেখুন।
প্রতিক্রিয়া
আপনার মতামত জেটপ্যাককে আরও উন্নত করতে সাহায্য করবে। আপনি যদি নতুন সমস্যা আবিষ্কার করেন অথবা এই লাইব্রেরি উন্নত করার জন্য কোন ধারণা থাকে তাহলে আমাদের জানান। নতুন একটি তৈরি করার আগে দয়া করে এই লাইব্রেরিতে বিদ্যমান সমস্যাগুলি একবার দেখে নিন। আপনি তারকা বোতামে ক্লিক করে বিদ্যমান সমস্যাটিতে আপনার ভোট যোগ করতে পারেন।
আরও তথ্যের জন্য ইস্যু ট্র্যাকার ডকুমেন্টেশন দেখুন।
সংস্করণ 2.10
সংস্করণ 2.10.0-rc01
০৫ নভেম্বর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-rc01 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-rc01-এ এই কমিটগুলি রয়েছে।
সংস্করণ 2.10.0-beta01
২২ অক্টোবর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-beta01 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-beta01-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
ViewModelStoreNavEntryDecoratorDefaultনাম পরিবর্তন করেViewModelStoreNavEntryDecoratorDefaultsরাখা হয়েছে, যার একটি 's' আছে। ( I6d27b , b/444447434 )
বাগ ফিক্স
-
Lifeycle.State.CREATEDএ যাওয়ার আগে মালিক যদিLifecycle.Event.ON_DESTROYইভেন্ট পান, তাহলেrememberLifecycleOwnerআর ক্র্যাশ হবে না। ( I6f98e , b/444594991 )
সংস্করণ 2.10.0-alpha05
৮ অক্টোবর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha05 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-alpha05-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
removeViewModelStoreOnPopCallback()এখন একটিViewModelStoreNavEntryDecoratorDefaultঅবজেক্টের অংশ যেখানে অন্যান্য প্ল্যাটফর্ম এবং বাস্তবায়নগুলি ডিফল্ট কল করতে পারে। ( Ia1f23 , b/444447434 ) -
NavEntryDecoratorএর জন্য একটি ফ্যাক্টরি হিসেবে এর কার্যকারিতা আরও ভালোভাবে প্রতিফলিত করার জন্যViewModelStoreNavEntryDecoratorএকটি ফাংশন থেকে একটি ক্লাসে রিফ্যাক্টর করা হয়েছে এবং ডেকোরেটরেরshouldRemoveViewModelStoreপ্যারামিটারের নাম পরিবর্তন করেremoveViewModelStoreOnPopকরা হয়েছে যাতে স্পষ্ট হয় যে এই কলব্যাকটি কেবল তখনই চালু হয় যখনbackStackথেকে একটি এন্ট্রি পপ করা হয়। ( Iefdc5 , b/444447434 )
সংস্করণ 2.10.0-alpha04
২৪ সেপ্টেম্বর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha04 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-alpha04-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
LifecycleOwnerকে রিফ্যাক্টর করুন যা LifecycleOwnerrememberLifecycleOwnerজন্য তৈরি করা যেতে পারে। ফাংশনটি এখন সরাসরিLifecycleOwnerরিটার্ন করে। এই মালিককে একটি সাব-কম্পোজিশনে প্রদান করতে,CompositionLocalProviderব্যবহার করুন। ( Ic57f0 , b/444446629 ) - lifecycle-viewmodel-navigation3 তে KMP স্টাব যোগ করুন যাতে JetBrains এই লক্ষ্যগুলি পূরণ করে এমন ফর্ক সরবরাহ করতে পারে এবং এইভাবে CMP সমর্থন করে। ( I44a4c )
সংস্করণ 2.10.0-alpha03
২৭ আগস্ট, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha03 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-alpha03-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
- কম্পোজ 1.9.0 এ আপডেট করুন। ( I2b9de )
সংস্করণ 2.10.0-alpha02
১৩ আগস্ট, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha02 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-alpha02-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
LifecycleOwnercomposable এখন একটি স্বতন্ত্র রুট লাইফসাইকেল তৈরি করতে পারে। (স্পষ্টভাবে)parent = nullসেট করে, নতুন লাইফসাইকেল যেকোনো হোস্ট (যেমনActivity,FragmentঅথবাNavBackStackEntry) থেকে স্বাধীনভাবে কাজ করে। কম্পোজেবল কম্পোজিশনে প্রবেশ করার সাথে সাথে এটি শুরু হয় এবং এটি বেরিয়ে যাওয়ার সাথে সাথে স্বয়ংক্রিয়ভাবে ধ্বংস হয়ে যায়। ( I8dfbe , b/433659048 )@Composable fun IndependentComponent() { // Create a standalone lifecycle, not tied to the parent Activity/Fragment. LifecycleOwner(parent = null) { val rootLifecycle = LocalLifecycleOwner.current.lifecycle } }
API পরিবর্তনগুলি
-
LifecycleOwnerকম্পোজেবলে,parentLifecycleOwnerপ্যারামিটারটির নাম পরিবর্তন করেparentরাখা হয়েছে। ( I080bc )
বাগ ফিক্স
-
LifecycleOwnercomposable এখন সঠিকভাবে নিষ্পত্তির পরে তার জীবনচক্রকেDESTROYEDতে স্থানান্তর করে। এটি জীবনচক্রের রেফারেন্স ধারণকারী বহিরাগত কোডের সম্ভাব্য লিক প্রতিরোধ করে। ( I9e5b7 , b/433659048 ) - ডিফল্ট minSdk কে API 21 থেকে API 23 এ স্থানান্তর করা হচ্ছে ( Ibdfca , b/380448311 , b/435705964 , b/435705223 )
বহিরাগত অবদান
-
LifecycleOwnerথেকে অপ্রয়োজনীয় অভ্যন্তরীণ ব্যাকিং ক্ষেত্রগুলি সরান। অবদানের জন্য জ্যাক ওয়ার্টনকে ধন্যবাদ। ( Ideddb )
সংস্করণ 2.10.0-alpha01
৩০ জুলাই, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha01 প্রকাশিত হয়েছে। সংস্করণ 2.10.0-alpha01-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
UI এর মধ্যে সরাসরি স্কোপড লাইফসাইকেল তৈরি করতে একটি
LifecycleOwnerকম্পোজেবল যোগ করুন। এটি এমন উপাদানগুলির জন্য কার্যকর যাদের তাদের নিজস্ব লাইফসাইকেল স্বাধীনভাবে পরিচালনা করতে হয়। Navigation3 কীভাবে এই নতুন কম্পোজেবলকে একীভূত করে তার একটি উদাহরণের জন্য, aosp/3708610 দেখুন। ( 76cbf7 )@Composable fun MyComposable() { LifecycleOwner( maxLifecycle = RESUMED, parentLifecycleOwner = LocalLifecycleOwner.current, ) { val childLifecycleOwner = LocalLifecycleOwner.current } }
API পরিবর্তনগুলি
-
CreationExtrasএর জন্য একটি বিল্ডার ফ্যাক্টরি ফাংশন যোগ করুন, যা আরও সুবিধাজনক এবং ইডিওম্যাটিক Kotlin API প্রদান করবে। ( Iab2bd ) -
SavedStateHandle.savedএ nullable প্রকারের জন্য নেটিভ সাপোর্ট যোগ করুন, nullable বৈশিষ্ট্য সংরক্ষণ এবং পুনরুদ্ধার সহজ করুন। ( I54d69 , b/421325690 ) -
SavedStateHandleকনস্ট্রাক্টরগুলিকে@VisibleForTestingহিসেবে চিহ্নিত করুন। ( Iff0e0 , b/408002794 )
সংস্করণ 2.9
সংস্করণ 2.9.4
১৭ সেপ্টেম্বর, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.4 প্রকাশিত হয়েছে। সংস্করণ 2.9.4-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- কম্পোজ কম্পাইলার প্লাগইন প্রয়োগ না করার ফলে লাইফসাইকেল KMP আর্টিফ্যাক্টগুলি ভেঙে যাওয়ার একটি ত্রুটি ঠিক করা হয়েছে। ( Ie95bc , b/443096483 , b/443965665 )
সংস্করণ 2.9.3
২৭ আগস্ট, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.3 প্রকাশিত হয়েছে। সংস্করণ 2.9.3-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
- লাইফসাইকেল
*-composeআর্টিফ্যাক্টে নতুন কোটলিন মাল্টিপ্ল্যাটফর্ম (KMP) টার্গেট যোগ করুন। লাইফসাইকেল এখন মোট নিম্নলিখিত প্ল্যাটফর্মগুলিকে সমর্থন করে: JVM (Android এবং ডেস্কটপ), নেটিভ (Linux, iOS, watchOS, macOS, MinGW), এবং ওয়েব (JavaScript, WasmJS)। ( I0a0e4 )
বাগ ফিক্স
-
androidx.annotation1.9.1 তে আপডেট করুন ( Ic9e4f , b/397701294 )
সংস্করণ 2.9.2
১৬ জুলাই, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.2 প্রকাশিত হয়েছে। সংস্করণ 2.9.2-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- লাইফসাইকেল আর্টিফ্যাক্টগুলিতে নতুন কোটলিন মাল্টিপ্ল্যাটফর্ম (KMP) টার্গেট যোগ করা হয়েছে। লাইফসাইকেল এখন মোট নিম্নলিখিত প্ল্যাটফর্মগুলিকে সমর্থন করে: JVM (Android এবং ডেস্কটপ), নেটিভ (Linux, iOS, watchOS, macOS, MinGW), এবং ওয়েব (JavaScript, WasmJS)। মনে রাখবেন যে
*-composeআর্টিফ্যাক্টগুলিতে কোনও নতুন KMP টার্গেট যোগ করা হয়নি, কারণ এটি Compose 1.9. ( I01cb8 ) এর স্থিতিশীল প্রকাশের উপর নির্ভর করে।
নির্ভরতা আপডেট
- নতুন KMP টার্গেটগুলির ( Ic9e4f , b/397701294 ) সমর্থন সক্ষম করার জন্য জীবনচক্র এখন অ্যানোটেশন
1.9.1উপর নির্ভর করে।
সংস্করণ 2.9.1
৪ জুন, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.1 প্রকাশিত হয়েছে। সংস্করণ 2.9.1-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
-
SavedStateHandle.remove(key)SavedStateHandle.getMutableStateFlow(key)অবস্থা সাফ করছে না তা ঠিক করুন। ( d5f939 , b/418746333 )
সংস্করণ 2.9.0
৭ মে, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-এ এই কমিটগুলি রয়েছে।
২.৮.০ থেকে গুরুত্বপূর্ণ পরিবর্তনগুলি
- একটি নতুন
androidx.lifecycle:lifecycle-viewmodel-testingKMP আর্টিফ্যাক্ট উপলব্ধ যাViewModelScenarioক্লাস প্রদান করে যা আইসোলেশনেViewModelsপরীক্ষা করে,onClearedএবংSavedStateHandleএর জন্য সমর্থন সহ, সেইসাথেrecreate()এর মাধ্যমে প্রক্রিয়া মৃত্যু এবং পুনর্গঠন পরীক্ষা করে। -
SavedStateHandleএgetMutableStateFlowযোগ করে একটিMutableStateFlowফিরিয়ে আনুন। এই নতুন ফাংশনটি কী-এক্সক্লুসিভ এবংgetLiveDataএর সাথে ব্যবহার করা যাবে না। একই অবস্থা অ্যাক্সেস করার জন্য উভয় ব্যবহার করার চেষ্টা করলে একটি ব্যতিক্রম দেখা যাবে। -
CreationExtrasএখন Kotlin-এ কন্টেন্টের ইডিওম্যাটিক ম্যানিপুলেশন সক্ষম করার জন্য মানচিত্রের মতো অপারেটর ওভারলোড অন্তর্ভুক্ত করে। এটিCreationExtrasসাথেin,+=, এবং+ব্যবহারের অনুমতি দেয়।
KotlinX সিরিয়ালাইজেশন সাপোর্ট
SavedState
1.3.0এ KotlinX Serialization এর সাপোর্ট যোগ করে, আমরাsaved, একটি lazy property delegate চালু করেছি, যাতেSavedStateHandleএ@Serializableক্লাসগুলি সংরক্ষণ করা সহজ হয় এবং প্রক্রিয়া মৃত্যু এবং পুনর্নির্মাণের সময় সেই ক্লাসগুলি স্বয়ংক্রিয়ভাবে পুনরুদ্ধার করা যায়। অনুগ্রহ করে মনে রাখবেন যেsavedডেলিগেটটি অলস এবং এটি অ্যাক্সেস না করা পর্যন্তinitlambda কল করবে না বাSavedStateHandleএ কিছু সংরক্ষণ করবে না।@Serializable data class Person(val firstName: String, val lastName: String) class MyViewModel(handle: SavedStateHandle) : ViewModel() { var person by handle.saved { Person("John", "Doe") } fun onPersonChanged(person: Person) { this.person = person } }
কোটলিন মাল্টিপ্ল্যাটফর্ম
-
lifecycle-testingমডিউলটি এখন KMP সামঞ্জস্যপূর্ণ, যার মধ্যেTestLifecycleOwnerএর মতো API গুলিও অন্তর্ভুক্ত। -
lifecycle-viewmodel-savedstateমডিউলটি এখন KMP-এর সাথে সামঞ্জস্যপূর্ণ, যার মধ্যেSavedStateHandleএর মতো API গুলিও অন্তর্ভুক্ত। -
androidx.compose.ui.platform.LocalLifecycleOwnerএখন কমন সোর্স সেটে উপলব্ধ। -
NewInstanceFactoryএখন JVM ডেস্কটপ এবং অ্যান্ড্রয়েড টার্গেটগুলিতে উপলব্ধ।
আচরণগত পরিবর্তন
-
Lifecycle.DESTROYEDঅবস্থাটি শেষ পর্যায়ে, এবং এটি থেকে অন্য কোনও রাজ্যে একটিLifecycleস্থানান্তরের যেকোনো প্রচেষ্টার ফলে এখন একটিIllegalStateExceptionতৈরি হবে। -
SavedStateHandleআর এমন কোনওSavedStateProvider.saveState()অন্তর্ভুক্ত করে না যেখানে ফেরত পাঠানোBundleখালি থাকে।
সংস্করণ 2.9.0-rc01
২৩ এপ্রিল, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-rc01 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-rc01-এ এই কমিটগুলি রয়েছে।
লিন্ট এপিআই সামঞ্জস্যতা সতর্কতা
- JetBrains
KaCallableMemberCallএকটি ক্লাস থেকে একটি ইন্টারফেসে পরিবর্তন করেছে, যা বাইনারি সামঞ্জস্যতা ভেঙে দেয়। যদি আপনার প্রকল্পের AGP সংস্করণটি লিন্ট চেক কম্পাইল করার জন্য ব্যবহৃত সংস্করণ থেকে আলাদা হয় তবে এটি ক্র্যাশ হতে পারে। এই আপডেটটি aosp/3577172 এ করা হয়েছিল কিন্তু রিলিজ নোট থেকে অনুপস্থিত ছিল — আমরা এখানে এটি স্পষ্ট করছি। প্রস্তাবিত সমাধান: সর্বশেষ স্থিতিশীল AGP-তে আপডেট করুন। যদি আপনি সম্পূর্ণরূপে আপডেট করতে না পারেন, তাহলে আপনার AGP সংস্করণের সাথে লিন্ট চেকগুলি সারিবদ্ধ করতেandroid.experimental.lint.versionব্যবহার করুন — বিস্তারিত জানার জন্য Compose Runtime আচরণ পরিবর্তনগুলি দেখুন।
সংস্করণ 2.9.0-beta01
৯ এপ্রিল, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-beta01 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-beta01-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
Lifecycle ViewModel Composeএখন কম্পোজ রানটাইম ১.৭.১ এবং তার পরবর্তী সংস্করণের মতো একই কোটলিন মাল্টিপ্ল্যাটফর্ম সেটআপ ব্যবহার করে --desktopআর্টিফ্যাক্টগুলি এখন সরানো হয়েছে এবং-jvmStubsএবং-linuxx64Stubsআর্টিফ্যাক্টগুলি যুক্ত করা হয়েছে। এই লক্ষ্যগুলির কোনওটিই ব্যবহারের জন্য নয়, এগুলি জেটব্রেইন কম্পোজ প্রচেষ্টায় সহায়তা করার জন্য স্থানধারক। ( I5cb14 , b/406592090 )
নির্ভরতা আপডেট
- এই লাইব্রেরিটি এখন Kotlin 2.0 ভাষা স্তরকে লক্ষ্য করে এবং KGP 2.0.0 বা তার পরবর্তী সংস্করণ প্রয়োজন। ( Idb6b5 )
-
Lifecycle ViewModel Composeএখন কম্পোজ ১.৭.৮ এর উপর নির্ভরশীল। ( I5cb14 , b/406592090 )
সংস্করণ 2.9.0-alpha13
২৬ মার্চ, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha13 কোনও উল্লেখযোগ্য পাবলিক পরিবর্তন ছাড়াই প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha13-এ এই কমিটগুলি রয়েছে।
সংস্করণ 2.9.0-alpha12
১২ মার্চ, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha12 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha12-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
- সকল সমর্থিত KMP প্ল্যাটফর্মে
ViewModelProvider.getএ@MainThreadঅ্যানোটেশন যোগ করুন। ( I7e8dd , b/397736115 ) -
SavedState*Delegatesনাম পরিবর্তন করেSavedState*Delegateকরুন। ( I8589b , b/399629301 )
সংস্করণ 2.9.0-alpha11
২৬ ফেব্রুয়ারী, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha11 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha11-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
saved()ডেলিগেটগুলিতেSavedStateConfigপ্যারামিটার যোগ করুন ( I39b3a )
সংস্করণ 2.9.0-alpha10
১২ ফেব্রুয়ারী, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha10 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha10-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
MutableStateSerializerlifecycle-viewmodel-composeথেকেsavedstate-composeএ সরান। ( I4f690 , b/378895074 )
বহিরাগত অবদান
- কম্পোজিশনে
Lifecycle::currentStateকল করার জন্য একটি নতুন Lint সমস্যা যোগ করা হয়েছে, পরিবর্তেcurrentStateAsalue().valueব্যবহার করার পরামর্শ দেওয়া হচ্ছে যাতে Lifecycle অবস্থায় পরিবর্তনগুলি সঠিকভাবে পুনর্গঠন ঘটায়। ধন্যবাদ Steven Schoen! ( Iad484 )
সংস্করণ 2.9.0-alpha09
২৯ জানুয়ারী, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha09 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha09-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
-
androidx.compose.runtime.MutableStateসিরিয়ালাইজ করার জন্যMutableStateSerializerযোগ করুন। ( Idfc48 , b/378895074 )
API পরিবর্তনগুলি
- ওভারলোডেড
SavedStateHandle.saved()ডেলিগেট ফাংশনগুলিকে ডিফল্ট প্যারামিটার দিয়ে প্রতিস্থাপন করুন ( Icd1c1 ) -
AbstractSavedStateViewModelFactoryবন্ধ করা হয়েছে কারণ এটি প্রতিটিViewModelএর জন্য একটিSavedStateHandleতৈরি করে, যার ফলে অপ্রয়োজনীয় ওভারহেড হয়। আরও দক্ষViewModelতৈরির জন্যCreationExtras.createSavedStateHandleএর সাথেViewModelProvider.Factoryব্যবহার করুন। ( Ia920b , b/388590327 )
সংস্করণ 2.9.0-alpha08
১১ ডিসেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha08 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha08-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
-
ViewModelScenario.recreateযোগ করুন যাতে একটি সিস্টেম প্রসেস ডেথ সিমুলেট করা যায় যা পরীক্ষার অধীনেViewModelএবং সমস্ত সংশ্লিষ্ট উপাদানগুলিকে পুনরায় তৈরি করে। ( Id6a69 , b/381063087 ) -
LifecycleOwnerএবংViewModelStoreOwnerদৃষ্টান্তগুলি তাদের নিজ নিজfindViewTreeAPI-এর মাধ্যমে পুনরুদ্ধার করা হয়েছে, এখনViewOverlayএর মতো কোনও ভিউয়ের ডিসজয়েন্ট প্যারেন্টের মাধ্যমে সমাধান করা যেতে পারে। ডিসজয়েন্ট ভিউ প্যারেন্ট সম্পর্কে আরও তথ্যের জন্য core-এর রিলিজ নোট বাViewTree.setViewTreeDisjointParentএর ডকুমেন্টেশন দেখুন। ( I800f4 )
API পরিবর্তনগুলি
-
SavedStateRegistryOwnerDelegate( I8c135 , b/376026744 ) এর সাথে নামকরণ এবং প্যাকেজ সংগঠনকে আরও সামঞ্জস্যপূর্ণ করুন।
বাগ ফিক্স
- এই লাইব্রেরিটি এখন JSpecify nullness annotations ব্যবহার করে, যা টাইপ-ব্যবহারের। সঠিক ব্যবহার জোরদার করার জন্য Kotlin ডেভেলপারদের নিম্নলিখিত কম্পাইলার আর্গুমেন্ট ব্যবহার করা উচিত:
-Xjspecify-annotations=strict(এটি Kotlin কম্পাইলারের 2.1.0 সংস্করণ থেকে শুরু করে ডিফল্ট)। ( Ie4340 , b/326456246 ) - ডকুমেন্ট
ViewModel.onClearedক্লিয়ারিং সিকোয়েন্স। ( I586c7 , b/363984116 )
সংস্করণ 2.9.0-alpha07
১৩ নভেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha07 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha07-এ এই কমিটগুলি রয়েছে।
কোটলিন মাল্টিপ্ল্যাটফর্ম সামঞ্জস্যতা
- Lifecycle
ViewModel SavedStateএখন KMP-এর সাথে সামঞ্জস্যপূর্ণ। এটি আপনাকে সাধারণ কোডেSavedStateHandleব্যবহার করতে দেয়। ( Ib6394 , b/334076622 )
KotlinX সিরিয়ালাইজেশন সাপোর্ট
SavedState
1.3.0-alpha05এ KotlinX Serialization এর সাপোর্ট যোগ করে, আমরাsaved, একটি lazy property delegate চালু করেছি, যাতেSavedStateHandleএ@Serializableক্লাসগুলি সংরক্ষণ করা সহজ হয় এবং প্রক্রিয়া মৃত্যু এবং পুনর্নির্মাণের সময় সেই ক্লাসগুলি স্বয়ংক্রিয়ভাবে পুনরুদ্ধার করা যায়। অনুগ্রহ করে মনে রাখবেন যেsavedডেলিগেটটি অলস এবং এটি অ্যাক্সেস না করা পর্যন্তinitlambda কল করবে না বাSavedStateHandleএ কিছু সংরক্ষণ করবে না। ( I47a88 , b/376026744 )@Serializable data class Person(val firstName: String, val lastName: String) class MyViewModel(handle: SavedStateHandle) : ViewModel() { var person by handle.saved { Person("John", "Doe") } fun onPersonChanged(person: Person) { this.person = person } }
API পরিবর্তনগুলি
-
SavedStateHandleএgetMutableStateFlowযোগ করে একটিMutableStateFlowফিরিয়ে আনুন। এই নতুন ফাংশনটি কী-এক্সক্লুসিভ এবংgetLiveDataএর সাথে ব্যবহার করা যাবে না। একই অবস্থায় অ্যাক্সেস করার জন্য উভয় ব্যবহার করার চেষ্টা করলে একটি ব্যতিক্রম দেখা যাবে। ( I04a4f , b/375408415 )
সংস্করণ 2.9.0-alpha06
৩০ অক্টোবর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha06 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha06-এ এই কমিটগুলি রয়েছে।
আচরণগত পরিবর্তন
-
Lifecycle.DESTROYEDঅবস্থাটি শেষ পর্যায়ে, এবং এটি থেকে অন্য কোনও রাজ্যে একটিLifecycleস্থানান্তরের যেকোনো প্রচেষ্টার ফলে এখন একটিIllegalStateExceptionতৈরি হবে। ( I116c4 , b/370577987 ) -
SavedStateHandleআর কোনওSavedStateProvider.saveState()অন্তর্ভুক্ত নেই যেখানে ফেরত দেওয়াBundleখালি থাকে। ( I910b5 , b/370577987 )
বাগ ফিক্স
-
Lifecycle.eventFlowএখন সঠিকভাবে সম্পূর্ণ হয়েছে যখনLifecycleDESTROYED( I293b2 , b/374043130 )
সংস্করণ 2.9.0-alpha05
১৬ অক্টোবর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha05 কোনও উল্লেখযোগ্য পরিবর্তন ছাড়াই প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha05-এ এই কমিটগুলি রয়েছে।
সংস্করণ 2.9.0-alpha04
২ অক্টোবর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha04 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha04-এ এই কমিটগুলি রয়েছে।
কোটলিন মাল্টিপ্ল্যাটফর্ম
-
lifecycle-viewmodel-savedstateমডিউলটি এখন KMP সামঞ্জস্যপূর্ণ হওয়ার জন্য কনফিগার করা হয়েছে, যাতে ভবিষ্যতের রিলিজেSavedStateHandleমতো API গুলি সাধারণ উৎস সেটে উপলব্ধ করা হবে। ( I503ed , I48764 , b/334076622 )
সংস্করণ 2.9.0-alpha03
১৮ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha03 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha03-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- লাইফসাইকেল
2.8.6থেকে:NullSafeMutableLiveDataLint ত্রুটিটি স্মার্ট কাস্টের জন্য সমর্থন উন্নত করেছে, মিথ্যা ইতিবাচকতা এড়িয়ে চলেছে। ( 85fed6 , b/181042665 )
নির্ভরতা আপডেট
- লাইফসাইকেল
2.8.6থেকে: লাইফসাইকেল রানটাইম কম্পোজ এখন কম্পোজ রানটাইম1.7.1উপর নির্ভরশীল। - লাইফসাইকেল রানটাইম এখন প্রোফাইল ইনস্টলার
1.4.0এর উপর নির্ভর করে
সংস্করণ 2.9.0-alpha02
৪ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha02 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha02-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- লাইফসাইকেল
2.8.5থেকে: অস্পষ্টতা দূর করতেandroidx.lifecycle.ReportFragmentProGuard নিয়ম আপডেট করুন। ( ff898e1 )
বহিরাগত অবদান
-
androidx.compose.ui.platform.LocalLifecycleOwnerকমন সোর্স সেট (KMP) এ সরান। অবদানের জন্য JetBrains থেকে ইভান ম্যাটকভকে ধন্যবাদ। ( 8cd5d03 ) - লাইফসাইকেল
2.8.5থেকে: SavedStateHandle.saveable` এক্সটেনশন ডেলিগেট এখন nullable মান সমর্থন করে। অবদানের জন্য ধন্যবাদ Roman Kalukiewicz। ( 0d78ea6 )
সংস্করণ 2.9.0-alpha01
৭ আগস্ট, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha01 প্রকাশিত হয়েছে। সংস্করণ 2.9.0-alpha01-এ এই কমিটগুলি রয়েছে।
কোটলিন মাল্টিপ্ল্যাটফর্ম
-
lifecycle-testingএখন KMP সামঞ্জস্যপূর্ণ। ( Iea41e ) -
linuxArm64kotlin মাল্টিপ্ল্যাটফর্ম টার্গেটের জন্য সমর্থন যোগ করুন ( I139d3 , b/338268719 )
নতুন বৈশিষ্ট্য
- একটি নতুন
androidx.lifecycle:lifecycle-viewmodel-testingKMP আর্টিফ্যাক্ট উপলব্ধ যাViewModelScenarioক্লাস প্রদান করে যা ViewModels কে আলাদাভাবে পরীক্ষা করে, যাonCleared(সমস্ত প্ল্যাটফর্ম) এবংSavedStateHandle(শুধুমাত্র Android) এর জন্য সমর্থন করে। ( 337f68d , c9b3409 , 9799a95c , b/264602919 ) -
ViewModelProviderদিয়েViewModelতৈরি করা এখন থ্রেড সেফ;@MainThreadঅ্যানোটেশনগুলি সরানো হয়েছে। ( Ifd978 , b/237006831 )
API পরিবর্তনগুলি
- বেনামী
CreationExtras.Keyঅবজেক্ট তৈরি সহজ করতেCreationExtras.Key()ফ্যাক্টরি ফাংশন যোগ করুন। ( I970ee ) -
CreationExtrasএখন Kotlin-এ কন্টেন্টের ইডিওম্যাটিক ম্যানিপুলেশন সক্ষম করার জন্য মানচিত্রের মতো অপারেটর ওভারলোড অন্তর্ভুক্ত করে। এটিCreationExtrasএর সাথেin,+=, এবং+ব্যবহারের অনুমতি দেয়। ( Ib4353 ) -
CreationExtrasএখনequals,hashCode, এবংtoStringপদ্ধতি প্রয়োগ করে। ( Ib4353 ) -
NewInstanceFactoryএখন JVM ডেস্কটপ এবং অ্যান্ড্রয়েড টার্গেটগুলিতে উপলব্ধ। ( d3d0892 ) - কোটলিন ভাষা সংস্করণ 2.0 ( I39df2 ) তে অন্তর্নিহিত অ্যাপ্লিকেশনটি নিরাপদে প্রকাশ করার জন্য ইনলাইন এক্সটেনশন সম্পত্তি
বাগ ফিক্স
- নতুন প্ল্যাটফর্ম API-তে অ্যাক্সেসের ম্যানুয়াল রূপরেখা সরানো হয়েছে কারণ এটি AGP 7.3 বা তার পরবর্তী সংস্করণ (যেমন R8 সংস্করণ 3.3) ব্যবহার করার সময় এবং AGP 8.1 বা তার পরবর্তী সংস্করণ (যেমন D8 সংস্করণ 8.1) ব্যবহার করার সময় সমস্ত বিল্ডের জন্য API মডেলিংয়ের মাধ্যমে স্বয়ংক্রিয়ভাবে ঘটে। যে ক্লায়েন্টরা AGP ব্যবহার করছেন না তাদের D8 সংস্করণ 8.1 বা তার পরবর্তী সংস্করণে আপডেট করার পরামর্শ দেওয়া হচ্ছে। আরও বিস্তারিত জানার জন্য এই নিবন্ধটি দেখুন। ( If6b4c , b/345472586 )
সংস্করণ 2.8
সংস্করণ 2.8.7
৩০ অক্টোবর, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.7 প্রকাশিত হয়েছে। সংস্করণ 2.8.7-এ এই কমিটগুলি রয়েছে।
API পরিবর্তনগুলি
-
androidx.compose.ui.platform.LocalLifecycleOwnerএখন কমন সোর্স সেট (KMP) তে উপলব্ধ। ( 6a3f5b3 ) -
lifecycle-runtime-compose:desktopআর্টিফ্যাক্টগুলি সরানো হয়েছে এবং-jvmStubsএবং-linuxx64Stubsআর্টিফ্যাক্টগুলি যোগ করা হয়েছে। এই টার্গেটগুলির কোনওটিই ব্যবহারের জন্য নয়, এগুলি Jetbrains Compose প্রচেষ্টায় সহায়তা করার জন্য স্থানধারক। ( 6a3f5b3 )
সংস্করণ 2.8.6
১৮ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.6 প্রকাশিত হয়েছে। সংস্করণ 2.8.6-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
-
NullSafeMutableLiveDataLint ত্রুটিটি স্মার্ট কাস্টের জন্য সমর্থন উন্নত করেছে, মিথ্যা ইতিবাচকতা এড়িয়ে চলেছে। ( 85fed6 , b/181042665 )
নির্ভরতা আপডেট
- লাইফসাইকেল রানটাইম কম্পোজ এখন কম্পোজ রানটাইম
1.7.1এর উপর নির্ভর করে
সংস্করণ 2.8.5
৪ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.5 প্রকাশিত হয়েছে। সংস্করণ 2.8.5-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- অস্পষ্টতা দূর করতে
androidx.lifecycle.ReportFragmentProGuard নিয়ম আপডেট করুন। ( ff898e1 )
বহিরাগত অবদান
-
SavedStateHandle.saveableএক্সটেনশন ডেলিগেট এখন nullable মান সমর্থন করে। অবদানের জন্য ধন্যবাদ Roman Kalukiewicz। ( 0d78ea6 )
সংস্করণ 2.8.4
২৪ জুলাই, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.4 প্রকাশিত হয়েছে। সংস্করণ 2.8.4-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
-
LiveData.asFlow()এখন সঠিকভাবে সেইসব ক্ষেত্রে পরিচালনা করে যেখানেLiveDataতে ইতিমধ্যেই সেট করা একটি মান পাওয়ার পরে (উদাহরণস্বরূপ,take(1)ব্যবহার করার সময়) ফেরত পাঠানো ফ্লো অবিলম্বে সম্পন্ন হয়। ( I9c566 ) -
Lifecycle*Effectসমাপ্তি এখন অক্ষম (অর্থাৎ, যদি জীবনচক্র বন্ধ থাকার কারণেonStopOrDisposeকল করা হয়, তাহলে নিষ্পত্তির পরে এটি দ্বিতীয়বার কল করা হবে না যদি না জীবনচক্র আবারSTARTEDএ ফিরে আসে)। ( I5f607 , b/352364595 )
সংস্করণ 2.8.3
১ জুলাই, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.3 প্রকাশিত হয়েছে। সংস্করণ 2.8.3-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- কোড সঙ্কুচিত করার সময় লাইফসাইকেল 2.8 এর কম্পোজ 1.6.0 এবং তার নিচের সংস্করণের সাথে ব্যাকওয়ার্ড সামঞ্জস্যের সমস্যা সমাধান করা হয়েছে। ( aosp/3133056 , b/346808608 )
সংস্করণ 2.8.2
১২ জুন, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.2 প্রকাশিত হয়েছে। সংস্করণ 2.8.2-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
- কম্পোজ ১.৬.এক্স বা তার আগের ভার্সনের সাথে লাইফসাইকেল ২.৮.এক্স ব্যবহার করার সময়
CompositionLocal LocalLifecycleOwner not present- এখন আপনি কোনও সমাধান ছাড়াই কম্পোজিশনের যেকোনো ভার্সনের সাথে লাইফসাইকেল ২.৮.২ ব্যবহার করতে পারবেন। ( aosp/3105647 , b/336842920 ) -
ViewModelProviderআরcompileOnlyLifecycle নির্ভরতার পূর্ববর্তী সংস্করণগুলিকে 2.8+ সংস্করণের সাথে মিশ্রিত করার সময় ক্র্যাশ করবে না, LeakCanary এর মতো লাইব্রেরির সমস্যাগুলি সমাধান করবে। ( I80383 , b/341792251 )
সংস্করণ 2.8.1
২৯ মে, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.1 প্রকাশিত হয়েছে। সংস্করণ 2.8.1-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
-
lifecycle-viewmodel-composeএখন শুধুমাত্রcompose-runtimeএর উপর একটি সাধারণ নির্ভরতা রয়েছে,compose-uiউপর এর সাধারণ নির্ভরতা সরিয়ে দিয়েছে। Android আর্টিফ্যাক্টটি সামঞ্জস্যের জন্য তারcompose-uiধরে রেখেছে। ( aosp/3079334 , b/339562627 ) -
ViewModelএরsaveableইন্টিগ্রেশন ব্যবহার করে প্রপার্টি ডেলিগেটস এখন স্বয়ংক্রিয়ভাবে তৈরি কী-এর অংশ হিসেবে ক্লাসের নাম ব্যবহার করে, একাধিক ক্লাস একইSavedStateHandleব্যবহার করলে দ্বন্দ্ব এড়ানো যায়। ( aosp/3063463 )
সংস্করণ 2.8.0
১৪ মে, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0 প্রকাশিত হয়েছে। সংস্করণ 2.8.0-এ এই কমিটগুলি রয়েছে।
২.৭.০ থেকে গুরুত্বপূর্ণ পরিবর্তনগুলি
-
LocalLifecycleOwnerCompose UI থেকেlifecycle-runtime-composeএ স্থানান্তরিত করা হয়েছে যাতে এর Compose-ভিত্তিক সহায়ক API গুলি Compose UI এর বাইরে ব্যবহার করা যায়। -
lifecycle-runtime-composeআর্টিফ্যাক্টে এখনdropUnlessResumedএবংdropUnlessStartedAPI রয়েছে যা আপনাকে ক্লিক বা অন্যান্য ইভেন্ট ড্রপ করতে দেয় যাLifecycleOwnerপ্রদত্তLifecycle.Stateনিচে নেমে যাওয়ার পরেও ঘটে। উদাহরণস্বরূপ, অন্য স্ক্রিনে রূপান্তর শুরু হওয়ার পরে ক্লিক ইভেন্টগুলি পরিচালনা করা এড়াতে এটি নেভিগেশন কম্পোজের সাথে ব্যবহার করা যেতে পারে:onClick: () -> Unit = dropUnlessResumed { navController.navigate(NEW_SCREEN) } ViewModel.viewModelScopeএখন একটি ওভাররাইডেবল কনস্ট্রাক্টর প্যারামিটার, যা আপনাকে আপনার নিজস্ব ডিসপ্যাচার এবংSupervisorJob()ইনজেক্ট করতে দেয় অথবাrunTestমধ্যে উপলব্ধbackgroundScopeব্যবহার করে ডিফল্ট ওভাররাইড করতে দেয়। ( I2817c , b/264598574 )class MyViewModel( // Make Dispatchers.Main the default, rather than Dispatchers.Main.immediate viewModelScope: CoroutineScope = Dispatchers.Main + SupervisorJob() ) : ViewModel(viewModelScope) { // Use viewModelScope as before, without any code changes } // Allows overriding the viewModelScope in a test fun Test() = runTest { val viewModel = MyViewModel(backgroundScope) }ViewModelKotlin এ পুনর্লিখন করা হয়েছে এবং এখনCloseableএর পরিবর্তেAutoClosableব্যবহার করে। এটি এখনAutoCloseableঅবজেক্ট যোগ করার জন্য একটিkeyব্যবহার করে যাgetCloseable()মাধ্যমে সেগুলি পুনরুদ্ধার করতে দেয়।এখন কী ছাড়া
LifecycleStartEffectএবংLifecycleResumeEffectকল করা একটি ত্রুটি, কারণ এই API গুলিDisposableEffectAPI এর মতো একই নিয়ম অনুসরণ করে।LiveDataReactiveStreams.toPublisher(lifecycleOwner, liveData)LiveData.toPublisher(lifecycleOwner)এর পরিবর্তে অপ্রচলিত করা হয়েছে।lifecycle-livedata-core-ktxkotlin এক্সটেনশনগুলি এখনlifecycle-livedata-coreমডিউলে স্থানান্তরিত করা হয়েছে।অনেক মিথ্যা ইতিবাচক তথ্য এড়াতে
NullSafeMutableLiveDataপুনঃফ্যাক্টর করা হয়েছে।
লাইফসাইকেল কোটলিন মাল্টিপ্ল্যাটফর্ম সামঞ্জস্যতা
Lifecycle , LifecycleOwner , LifecycleObserver , Lifecycle.State , Lifecycle.Event , এবং LifecycleRegistry এর মূল Lifecycle API গুলি এখন Kotlin Multiplatform-এর সাথে সামঞ্জস্যপূর্ণ আর্টিফ্যাক্টে পাঠানো হয়।
প্রভাবিত শিল্পকর্ম:
-
lifecycle-commonবেশিরভাগ API গুলিকেcommonএ স্থানান্তর করে এবং Android ছাড়াও jvm এবং iOS সমর্থন করে। -
lifecycle-runtimeবেশিরভাগ API গুলিকেcommonএ স্থানান্তর করে এবং অ্যান্ড্রয়েড ছাড়াও jvm এবং iOS সমর্থন করে। -
lifecycle-runtime-ktxএখন খালি, সমস্ত API গুলিlifecycle-runtimeএ স্থানান্তরিত হচ্ছে। -
lifecycle-runtime-composeসমস্ত API গুলিকেcommonএ স্থানান্তর করে এবংandroidx.composeএর মাল্টিপ্ল্যাটফর্ম সাপোর্টের সাথে মিলে একটি Android আর্টিফ্যাক্ট সরবরাহ করে।
ভিউমডেল কোটলিন মাল্টিপ্ল্যাটফর্ম সামঞ্জস্যতা
lifecycle-viewmodel আর্টিফ্যাক্ট এবং ViewModel , ViewModelStore , ViewModelStoreOwner , এবং ViewModelProvider এর মতো API গুলি এখন Kotlin Multiplatform এর সাথে সামঞ্জস্যপূর্ণ আর্টিফ্যাক্টে পাঠানো হয়।
এই পরিবর্তনটি সামঞ্জস্য করার জন্য, ViewModelProvider এর মতো পদ্ধতিগুলি যেগুলি java.lang.Class<T> নিয়েছে এখন একটি সমতুল্য পদ্ধতি রয়েছে যা kotlin.reflect.KClass<T> নেয়।
অ্যান্ড্রয়েডে বাইনারি সামঞ্জস্যতা বজায় রাখা হয়েছে, তবে সাধারণ API পৃষ্ঠের সাথে অ্যান্ড্রয়েড API পৃষ্ঠের তুলনা করার সময় কয়েকটি উল্লেখযোগ্য পরিবর্তন দেখা যায়:
- একটি
ViewModelProviderইনস্ট্যান্স তৈরি করা এখন সরাসরি কনস্ট্রাক্টরকে কল করার পরিবর্তেViewModelProvider.create()পদ্ধতির মাধ্যমে করা হয়। -
ViewModelProvider.NewInstanceFactoryএবংViewModelProvider.AndroidViewModelFactoryশুধুমাত্র Android এ উপলব্ধ।- কাস্টম ফ্যাক্টরিগুলিকে
ViewModelProvider.Factoryথেকে প্রসারিত করার এবংcreateপদ্ধতি ব্যবহার করার পরামর্শ দেওয়া হচ্ছে যাCreationExtrasনেয় অথবাviewModelFactoryKotlin DSL ব্যবহার করে।
- কাস্টম ফ্যাক্টরিগুলিকে
- JVM-বহির্ভূত প্ল্যাটফর্মগুলিতে কাস্টম ফ্যাক্টরি ছাড়া
ViewModelProviderব্যবহার করলেUnsupportedOperationExceptionতৈরি হবে। JVM প্ল্যাটফর্মগুলিতে, যদি কাস্টম ফ্যাক্টরি প্রদান না করা হয় তবে no-args ViewModel কনস্ট্রাক্টর ব্যবহার করে সামঞ্জস্যতা সংরক্ষণ করা হয়। -
viewModelScopeএমন প্ল্যাটফর্মগুলিতেEmptyCoroutineContextএ ফিরে যাবে যেখানেDispatchers.Mainউপলব্ধ নেই (যেমন, Linux)।
প্রভাবিত শিল্পকর্ম:
-
lifecycle-viewmodelবেশিরভাগ API গুলিকেcommonএ স্থানান্তর করে এবং Android ছাড়াও jvm এবং iOS সমর্থন করে। -
lifecycle-viewmodel-ktxএখন খালি, সমস্ত API গুলিlifecycle-viewmodelএ স্থানান্তরিত হচ্ছে। -
lifecycle-viewmodel-composeসমস্ত API গুলিকেcommonএ স্থানান্তর করে এবংandroidx.composeএর মাল্টিপ্ল্যাটফর্ম সাপোর্টের সাথে মিলে একটি Android আর্টিফ্যাক্ট সরবরাহ করে।
আচরণগত পরিবর্তন
- যদি একই
clazz: KClass<VM : ViewModel>সহ একটিinitializerইতিমধ্যেই যোগ করা হয়ে থাকে, তাহলেInitializerViewModelFactory(viewModelFactoryবিল্ডার ফাংশন সহ) এখন একটিIllegalArgumentExceptionনিক্ষেপ করবে। ( Ic3a36 )
জ্ঞাত সমস্যা
-
lifecycle-*:2.8.0এর জন্য ন্যূনতম 1.7.0-alpha05 ( b/336842920 ) কম্পোজ সংস্করণ প্রয়োজন।
সংস্করণ 2.8.0-rc01
১ মে, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-rc01 প্রকাশিত হয়েছে। সংস্করণ 2.8.0-rc01-এ এই কমিটগুলি রয়েছে।
বাগ ফিক্স
-
lifecycle-commonক্লাসের জন্য বেসলাইন প্রোফাইল সঠিকভাবে প্যাকেজ না করার সমস্যাটি সমাধান করা হয়েছে। এগুলি এখনlifecycle-runtimeAAR-তে প্যাকেজ করা হয়েছে। ( aosp/3038274 , b/322382422 ) - ViewModel-এর সাথে সংযুক্ত
AutoCloseableইনস্ট্যান্সগুলি কীভাবে সাফ করা হয় তার অনিচ্ছাকৃত ক্রম পরিবর্তন সংশোধন করা হয়েছে -addCloseable(String, AutoCloseable), তারপরaddClosable(AutoCloseable), তারপরonCleared()এর পূর্ববর্তী ক্রম পুনরুদ্ধার করা হয়েছে। ( aosp/3041632 ) - নেটিভ এবং JVM ডেস্কটপ পরিবেশের জন্য
viewModelScopeএর ডিফল্ট তৈরির আচরণ উন্নত করুন। ( aosp/3039221 )
বহিরাগত অবদান
- JVM ডেস্কটপে মূল থ্রেডের চেকিং উন্নত করার জন্য ভিক্টর ক্রপকে ধন্যবাদ। ( aosp/3037116 )
সংস্করণ 2.8.0-beta01
১৭ এপ্রিল, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-beta01 প্রকাশিত হয়েছে। সংস্করণ 2.8.0-beta01-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
-
lifecycle-runtime-composeআর্টিফ্যাক্টটি এখন কোটলিন মাল্টিপ্ল্যাটফর্মের সাথে সামঞ্জস্যপূর্ণ, এর কোডটিcommon-এ স্থানান্তরিত করে এবং একটি অ্যান্ড্রয়েড আর্টিফ্যাক্ট সরবরাহ করে, যাandroidx.composeএর জন্য মাল্টিপ্ল্যাটফর্ম সাপোর্টের সাথে মিলে যায়। ( If7a71 , I4f4a0 , b/331769623 )
সংস্করণ 2.8.0-alpha04
৩ এপ্রিল, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-alpha04 প্রকাশিত হয়েছে। সংস্করণ 2.8.0-alpha04-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
-
lifecycle-viewmodel-composeআর্টিফ্যাক্টটি এখন Kotlin Multiplatform এর সাথে সামঞ্জস্যপূর্ণ, এর কোডটিcommonএ স্থানান্তরিত করে এবংandroidx.composeএর মাল্টিপ্ল্যাটফর্ম সাপোর্টের সাথে মিলে একটি Android আর্টিফ্যাক্ট সরবরাহ করে। এই পরিবর্তনটি সামঞ্জস্য করার জন্য, ComposableviewModelপদ্ধতিটি এখনjava.lang.Classএর পাশাপাশি একটিKClassগ্রহণ করে। ( b/330323282 )
বাগ ফিক্স
- অনেক মিথ্যা পজিটিভ এড়াতে
NullSafeMutableLiveDataপুনঃফ্যাক্টর করা হয়েছে। ( I2d8c1 , Iafb18 , I03463 , I7ecef )
নির্ভরতা আপডেট
-
lifecycle-viewmodel-composeআর্টিফ্যাক্ট এখন কম্পোজ ১.৬.০ এর উপর নির্ভর করে। - জীবনচক্র এখন প্রোফাইল ইনস্টলার 1.3.1 এর উপর নির্ভর করে।
সংস্করণ 2.8.0-alpha03
২০ মার্চ, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-alpha03 প্রকাশিত হয়েছে। সংস্করণ 2.8.0-alpha03-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
ViewModel.viewModelScopeএখন একটি ওভাররাইডেবল কনস্ট্রাক্টর প্যারামিটার, যা আপনাকে আপনার নিজস্ব ডিসপ্যাচার এবংSupervisorJob()ইনজেক্ট করতে দেয় অথবাrunTestমধ্যে উপলব্ধbackgroundScopeব্যবহার করে ডিফল্ট ওভাররাইড করতে দেয়। ( I2817c , b/264598574 )class MyViewModel( // Make Dispatchers.Main the default, rather than Dispatchers.Main.immediate viewModelScope: CoroutineScope = Dispatchers.Main + SupervisorJob() ) : ViewModel(viewModelScope) { // Use viewModelScope as before, without any code changes } // Allows overriding the viewModelScope in a test fun Test() = runTest { val viewModel = MyViewModel(backgroundScope) }
কোটলিন মাল্টিপ্ল্যাটফর্ম সামঞ্জস্যতা
lifecycle-viewmodel আর্টিফ্যাক্ট এবং ViewModel , ViewModelStore , ViewModelStoreOwner , এবং ViewModelProvider এর মতো API গুলি এখন Kotlin Multiplatform এর সাথে সামঞ্জস্যপূর্ণ আর্টিফ্যাক্টে পাঠানো হচ্ছে। ( b/214568825 )
এই পরিবর্তনটি সামঞ্জস্য করার জন্য, ViewModelProvider এর মতো পদ্ধতিগুলি যেগুলি java.lang.Class<T> নিয়েছে এখন একটি সমতুল্য পদ্ধতি রয়েছে যা kotlin.reflect.KClass<T> নেয়।
অ্যান্ড্রয়েডে বাইনারি সামঞ্জস্যতা বজায় রাখা হয়েছে, তবে সাধারণ API পৃষ্ঠের সাথে অ্যান্ড্রয়েড API পৃষ্ঠের তুলনা করার সময় কয়েকটি উল্লেখযোগ্য পরিবর্তন দেখা যায়:
- একটি
ViewModelProviderইনস্ট্যান্স তৈরি করা এখন সরাসরি কনস্ট্রাক্টরকে কল করার পরিবর্তেViewModelProvider.create()পদ্ধতির মাধ্যমে করা হয়। -
ViewModelProvider.NewInstanceFactoryএবংViewModelProvider.AndroidViewModelFactoryশুধুমাত্র Android এ উপলব্ধ।- কাস্টম ফ্যাক্টরিগুলিকে
ViewModelProvider.Factoryথেকে প্রসারিত করার এবংcreateপদ্ধতি ব্যবহার করার পরামর্শ দেওয়া হচ্ছে যাCreationExtrasনেয় অথবাviewModelFactoryKotlin DSL ব্যবহার করে।
- কাস্টম ফ্যাক্টরিগুলিকে
- JVM-বহির্ভূত প্ল্যাটফর্মগুলিতে কাস্টম ফ্যাক্টরি ছাড়া
ViewModelProviderব্যবহার করলেUnsupportedOperationExceptionতৈরি হবে। JVM প্ল্যাটফর্মগুলিতে, যদি কাস্টম ফ্যাক্টরি প্রদান না করা হয় তবে no-args ViewModel কনস্ট্রাক্টর ব্যবহার করে সামঞ্জস্যতা সংরক্ষণ করা হয়। -
viewModelScopeএমন প্ল্যাটফর্মগুলিতেEmptyCoroutineContextএ ফিরে যাবে যেখানেDispatchers.Mainউপলব্ধ নেই (যেমন, Linux)।
আচরণগত পরিবর্তন
- যদি একই
clazz: KClass<VM : ViewModel>সহ একটিinitializerইতিমধ্যেই যোগ করা হয়ে থাকে, তাহলেInitializerViewModelFactory(viewModelFactoryবিল্ডার ফাংশন সহ) এখন একটিIllegalArgumentExceptionনিক্ষেপ করবে। ( Ic3a36 )
বাগ ফিক্স
-
ViewModel.getCloseableএখন ডুপ্লিকেট করা কীগুলি পরিচালনা করে: যদিkeyইতিমধ্যেই একটিAutoCloseableরিসোর্স যুক্ত থাকে, তাহলে পুরানো রিসোর্সটি প্রতিস্থাপন করা হবে এবং অবিলম্বে বন্ধ করে দেওয়া হবে। ( Ibeb67 ) -
ViewModelএরviewModelScopeঅ্যাক্সেস করা এখন থ্রেড নিরাপদ। ( If4766 , b/322407038 )
বহিরাগত অবদান
-
LocalLifecycleOwnerCompose UI থেকে lifecycle-runtime-compose-এ স্থানান্তরিত হয়েছে যাতে এর Compose-ভিত্তিক সহায়ক API গুলি Compose UI-এর বাইরে ব্যবহার করা যায়। অবদানের জন্য ধন্যবাদ জ্যাক ওয়ার্টন। ( I6c41b , b/328263448 )
সংস্করণ 2.8.0-alpha02
২১ ফেব্রুয়ারী, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-alpha02 প্রকাশিত হয়েছে। সংস্করণ 2.8.0-alpha02-এ এই কমিটগুলি রয়েছে।
নতুন বৈশিষ্ট্য
-
dropUnlessResumedএবংdropUnlessStartedAPI গুলি যোগ করা হয়েছে যা আপনাকেLifecycleOwnerপ্রদত্তLifecycle.Stateএর নিচে নেমে যাওয়ার পরেও ড্রপ ক্লিক বা অন্যান্য ইভেন্টগুলি করতে দেয়। উদাহরণস্বরূপ, অন্য স্ক্রিনে রূপান্তর শুরু হওয়ার পরে ক্লিক ইভেন্টগুলি পরিচালনা করা এড়াতে এটি নেভিগেশন কম্পোজের সাথে ব্যবহার করা যেতে পারে:onClick: () -> Unit = dropUnlessResumed { navController.navigate(NEW_SCREEN) }( Icba83 , b/317230685 )
কোটলিন রূপান্তর
-
ViewModelএখন Kotlin ( I16f26 , b/214568825 ) ভাষায় লেখা আছে। -
lifecycle-viewmodel-ktxkotlin এক্সটেনশনগুলি এখন বেস লাইফসাইকেল মডিউলে স্থানান্তরিত করা হয়েছে। ( Id787b , b/274800183 ) -
lifecycle-runtime-ktxkotlin এক্সটেনশনগুলি এখন বেস লাইফসাইকেল মডিউলে স্থানান্তরিত করা হয়েছে। ( Ic3686 , b/274800183 ) -
lifecycle-livedata-core-ktxkotlin এক্সটেনশনগুলি এখন বেস লাইফসাইকেল মডিউলে স্থানান্তরিত করা হয়েছে। ( I54a3d , b/274800183 )
কোটলিন মাল্টিপ্ল্যাটফর্ম সামঞ্জস্যতা
-
Lifecycle,LifecycleOwner,LifecycleObserver,Lifecycle.State,Lifecycle.Event, এবংLifecycleRegistryএর মূল Lifecycle API গুলি এখন Kotlin Multiplatform-এর সাথে সামঞ্জস্যপূর্ণ আর্টিফ্যাক্টে পাঠানো হয়। ( b/317249252 )
API পরিবর্তনগুলি
- কী ছাড়া
LifecycleStartEffectএবংLifecycleResumeEffectকল করা এখন একটি ত্রুটি, কারণ এই API গুলিDisposableEffectAPI এর মতো একই নিয়ম অনুসরণ করে। ( Ib0e0c , b/323518079 ) -
ViewModelnow usesAutoCloseableinstead ofCloseable. That is a backward compatible change. ( I27f8e , b/214568825 ) - Deprecated
LiveDataReactiveStreams.toPublisher(lifecycleOwner, liveData)in favor ofLiveData.toPublisher(lifecycleOwner). ( Iabe29 , b/262623005 )
External Contribution
- Thanks Ivan Matkov from Jetbrains for helping move Lifecycle to Kotlin Multiplatform. ( aosp/2926690 , I0c5ac , If445d )
Version 2.8.0-alpha01
January 24, 2024
androidx.lifecycle:lifecycle-*:2.8.0-alpha01 is released. Version 2.8.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
-
ViewModelnow supports addingCloseableobjects with akeythat allows retrieving them viagetCloseable(). ( I3cf63 )
Version 2.7
সংস্করণ 2.7.0
January 10, 2024
androidx.lifecycle:lifecycle-*:2.7.0 is released. Version 2.7.0 contains these commits.
Important changes since 2.6.0
-
TestLifecycleOwnernow includes a suspending functionsetCurrentState()which ensures that the state change and allLifecycleObservercallbacks are completed before returning. Notably, unlike setting thecurrentStateproperty directly, this does not userunBlocking, making it safe to use within a coroutine such as one provided byrunTest. - The
LiveDataextensions ofmapandswitchMapnow mirror the behavior ofdistinctUntilChanged- if theLiveDatahas avalueset, themap/switchMapfunction will be immediately called to populate thevalueof the returnedLiveData. This ensures that the initial value will be set as part of the first composition (when used withobserveAsState()), but does not change the observation behavior - updates values from the sourceLiveDatawill still only apply once you start observing theLiveData. - This release fixes an issue where
SavedStateHandlewould not properly restore customParcelableclasses after process death and recreation. Due to type information that is lost by the Android framework, arrays of custom Parcelables require additional work (manually creating a typed array of the right type) and the documentation onget,getLiveData, andgetStateFlownow specifically calls this limitation out. - The proguard keep rules associated with
LifecycleObserverhave been removed. This means that proguarded code that wishes to use APIs via reflection (such as using the long since deprecated@OnLifecycleEventannotation) will need to provide their own keep rules for their specific use case.
Lifecycle Event Observability
- As an alternative to using a
LifecycleEventObserver, you can now observe aFlowofLifecycle.Eventvia theLifecycle.asFlow()extension method. - Jetpack Compose users can now use
LifecycleEventEffectto run Compose side effects based onLifecycle.Event.
@Composable
fun HomeScreen(viewModel: HomeViewModel = viewModel()) {
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
viewModel.refreshData()
}
// …
}
- Jetpack Compose users can use
LifecycleStartEffectandLifecycleResumeEffectto handle pairs of events - started to stopped and resumed to paused, respectively. This API mirrors the one found inDisposableEffectand is suitable for cases where the change being made when the state is going up needs to be reversed when going back down.
fun HomeScreen(viewModel: HomeViewModel = viewModel()) {
LifecycleStartEffect(viewModel) {
val timeTracking = viewModel.startTrackingTimeOnScreen()
onStopOrDispose {
timeTracking.stopTrackingTimeOnScreen()
}
}
// …
}
See Run code on lifecycle events for more information.
Lifecycle State Observability
- The current
Lifecycle.Statecan now be observed via theLifecycle.currentStateFlowproperty, which returns aStateFlowwhere thevalueis the currentLifecycle.State. - Jetpack Compose users can use the
Lifecycle.currentStateAsState()extension to directly exposeLifecycle.Stateas ComposeState. This is equivalent (and a shorter alternative) tolifecycle.currentStateFlow.collectAsState().
See Collect lifecycle state with flows for more information.
Version 2.7.0-rc02
১৩ ডিসেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-rc02 is released. Version 2.7.0-rc02 contains these commits.
Bug Fixes
- Fixed an issue where
SavedStateHandlewould not properly restore customParcelableclasses after process death and recreation. Due to type information that is lost by the Android framework, arrays of custom Parcelables require additional work (manually creating a typed array of the right type) and the documentation onget,getLiveData, andgetStateFlownow specifically calls this limitation out. ( I0b55a )
Version 2.7.0-rc01
১৫ নভেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-rc01 is released. Version 2.7.0-rc01 contains these commits.
Bug Fixes
-
LifecycleStartEffectandLifecycleResumeEffectnow correctly dispose and recreate the effect block if theLifecycleOwneris changed. ( Ia25c6 )
Version 2.7.0-beta01
১ নভেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-beta01 is released with no changes. Version 2.7.0-beta01 contains these commits.
- A beta version bump, no major changes to this release version.
Version 2.7.0-alpha03
October 18, 2023
androidx.lifecycle:lifecycle-*:2.7.0-alpha03 is released. Version 2.7.0-alpha03 contains these commits.
নতুন বৈশিষ্ট্য
-
lifecycle-runtime-testingnow contains a new Lint check to avoid setting theLifecycle.Stateof theTestLifecycleOwnerby using thecurrentStatefield when inside of a coroutine. The Lint check now suggests the suspendingsetCurrentStatewhich allows setting theLifecycle.Statewithout blocking. ( Icf728 , b/297880630 )
Bug Fixes
- Fixed an issue with
LiveData.switchMapwhere returning the sameLiveDatainstance both on the initial call and a subsequent call would prevent theLiveDatainstance from being added as a source. ( Ibedcba7 )
Version 2.7.0-alpha02
৬ সেপ্টেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-alpha02 is released. Version 2.7.0-alpha02 contains these commits.
নতুন বৈশিষ্ট্য
-
TestLifecycleOwnernow includes the suspending functionsetCurrentState()to give users the option of usingTestLifecycleOwnerfrom within a coroutine such as one provided byrunTest. ( I329de , b/259344129 )
API Changes
- All files from the
lifecycle-livedata-ktxmodules have been moved into the mainlifecycle-livedatamodule. ( I10c6f , b/274800183 )
আচরণগত পরিবর্তন
- The
LiveData.map()andLiveData.switchMap()extensions now sets thevalueof the returnedLiveDataif the previousLiveDatahas had a value set on it, ensuring that using the resulting LiveData in Jetpack Compose has the right state on the initial composition. ( I91d2b , b/269479952 ) -
ViewModel'saddCloseable()now immediately closes theCloseableif theViewModelhas already received a call toonCleared(). ( I4712e , b/280294730 )
Bug Fixes
- From Lifecycle
2.6.2: Fixed an issue whereSavedStateHandlewould not correctly be restored after process death if the state was restored,save()was called without actually saving the state in the parentSavedStateRegistry, and then the state was restored again. This fixes the interaction betweenrememberSaveableand Navigation Compose'sNavHost. ( aosp/2729289 )
Version 2.7.0-alpha01
July 26, 2023
androidx.lifecycle:lifecycle-*:2.7.0-alpha01 is released. Version 2.7.0-alpha01 contains these commits.
API Changes
-
Lifecycle.Stateis now Compose-observable viaLifecycle.currentStateFlow, which returns aStateFlowwhere thevalueis the currentLifecycle.State. ( Ib212d , b/209684871 ) -
Lifecycle.Events can now able to be observed as aFlowwithLifecycle.asFlow().( If2c0f , b/176311030 ) -
LifecycleResumeEffectAPI has been added to run ComposeSideEffects based on bothLifecycle.Event.ON_RESUMEandLifecycle.Event.ON_PAUSEevent callbacks. ( I60386 , b/235529345 ) -
LifecycleStartEffectAPI has been added to run ComposeSideEffects based onLifecycle.Event.ON_STARTandLifecycle.Event.ON_STOPevent callbacks. ( I5a8d1 , b/235529345 ) -
LifecycleEventEffectAPI has been added to run ComposeSideEffects based onLifecycle.Event. ( Ic9794 , b/235529345 ) -
Lifecycle.collectAsState()extension has been added to directly exposeLifecycle.Stateas ComposeState. This is equivalent (and a shorter alternative) tolifecycle.currentStateFlow.collectAsState(). ( I11015 , b/235529345 )
Bug Fixes
- The
LiveData.distinctUntilChanged()extension now sets thevalueof the returnedLiveDataif the previousLiveDatahas had a value set on it. This does not change the observation behavior - updated values from the sourceLiveDatawill still only apply once you start observing theLiveDatareturned fromdistinctUntilChanged(). ( Ib482f ) - The proguard keep rules associated with
LifecycleObserverhave been removed. This means that proguarded code that wishes to use APIs via reflection will need to provide their own keep rules for their specific use case. ( Ia12fd )
Version 2.6
Version 2.6.2
৬ সেপ্টেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.2 is released. Version 2.6.2 contains these commits.
Bug Fixes
- Fixed an issue where
SavedStateHandlewould not correctly be restored after process death if the state was restored,save()was called without actually saving the state in the parentSavedStateRegistry, and then the state was restored again. This fixes the interaction betweenrememberSaveableand Navigation Compose'sNavHost. ( aosp/2729289 )
Version 2.6.1
২২ মার্চ, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.1 is released. Version 2.6.1 contains these commits.
Dependency Updates
-
lifecycle-viewmodel-savedstatenow depends on SavedState1.2.1. ( cd7251 ) - Lifecycle now depends on ProfileInstaller
1.3.0. ( f9d30b )
সংস্করণ 2.6.0
৮ মার্চ, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0 is released. Version 2.6.0 contains these commits.
Important changes since 2.5.0
-
LiveDatanow includes a newisInitializedproperty that indicates whether an explicit value has ever been set on theLiveData, allowing you to distinguish betweenliveData.valuereturningnullbecause no value has ever been set or an explicitnullvalue. -
MediatorLiveDatanow includes a constructor to set an initial value. - Added a new extension on
StateFlowandFlowofcollectAsStateWithLifecycle()that collect from flows and represents its latest value as Compose State in a lifecycle-aware manner. -
Lifecycle.launchWhenXmethods andLifecycle.whenXmethods have been deprecated as the use of a pausing dispatcher can lead to wasted resources in some cases. It is recommended to useLifecycle.repeatOnLifecycle. For more information about one-time suspending work, please see this explanation on why this is inherently unsafe. - Kotlin Conversion - A large number of Lifecycle classes have been converted to Kotlin. All converted classes still retain their binary compatibility with previous versions. The following classes have source incompatible changes for classes written in Kotlin:
ViewTreeLifecycleOwner,LiveDataReactiveStreams,HasDefaultViewModelProviderFactory,ViewTreeViewModelStoreOwner,Transformations,ViewModelStoreOwner,LifecycleOwner
The table below provides the source conversions for the new version of lifecycle.
| Lifecycle 2.5 | Lifecycle 2.5 (KTX) | Lifecycle 2.6 |
|---|---|---|
Transformations.switchMap(liveData) {...} | liveData.switchMap {...} | liveData.switchMap {...} |
Transformations.map(liveData) {...} | liveData.map {...} | liveData.map {...} |
Transformations.distinctUntilChanged(liveData) {...} | liveData.distinctUntilChanged{...} | liveData.distinctUntilChanged{...} |
LiveDataReactiveStreams.fromPublisher(publisher) | publisher.toLiveData() | publisher.toLiveData() |
LiveDataReactiveStreams.toPublisher(lifecycleOwner, liveData) | liveData.toPublisher(lifecycleOwner) | liveData.toPublisher(lifecycleOwner) |
override fun getDefaultViewModelProviderFactory(): ViewModelProvider.Factory = factory | override fun getDefaultViewModelProviderFactory(): ViewModelProvider.Factory = factory | override val defaultViewModelProviderFactory = factory |
override fun getDefaultViewModelCreationExtras(): CreationExtras = extras | override fun getDefaultViewModelCreationExtras(): CreationExtras = extras | override val defaultViewModelProviderCreationExtras = extras |
ViewTreeLifecycleOwner.set(view, owner) | ViewTreeLifecycleOwner.set(view, owner) | view.setViewTreeLifecycleOwner(owner) |
ViewTreeLifecycleOwner.get(view) | view.findViewTreeLifecycleOwner() | view.findViewTreeLifecycleOwner() |
override fun getViewModelStore(): ViewModelStore = store | override fun getViewModelStore(): ViewModelStore = store | override val viewModelStore: ViewModelStore = store |
override fun getLifecycle(): Lifecycle = registry | override fun getLifecycle(): Lifecycle = registry | override val lifecycle: Lifecycle get() = registry |
- The nullability of the
onChangedmethod of aObservercreated in Kotlin now matches the nullability of the generic type. If you wantObserver.onChanged()to accept a nullable type, you must instantiate theObserverwith a nullable type. - These classes were also converted to Kotlin, but remain source compatible:
DefaultLifecycleObserver,LifecycleEventObserver,Lifecycle,LifecycleRegistry,LifecycleObserver,ViewModelStore,AndroidViewModel,AbstractSavedStateViewModelFactory,LifecycleService,ServiceLifecycleDispatcher, andProcessLifecycleOwner
Version 2.6.0-rc01
February 22, 2023
androidx.lifecycle:lifecycle-*:2.6.0-rc01 is released. Version 2.6.0-rc01 contains these commits.
Bug Fixes
- The
LiveData.distinctUntilChanged()extension now sets thevalueof the returnedLiveDataif the previousLiveDatahas had a value set on it. This does not change the observation behavior - updated values from the sourceLiveDatawill still only apply once you start observing theLiveDatareturned fromdistinctUntilChanged(). ( Ib482f )
Version 2.6.0-beta01
৮ ফেব্রুয়ারী, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0-beta01 is released. Version 2.6.0-beta01 contains these commits.
Kotlin Conversions
-
LifecycleOwneris now written in Kotlin. This is a source incompatible change for classes written in Kotlin - they must now override thelifecycleproperty rather than implementing the previousgetLifecycle()function. ( I75b4b , b/240298691 ) -
ViewModelStoreOwneris now in Kotlin. This is a source incompatible change for classes written in Kotlin - they must now override theviewModelStoreproperty rather than implementing the previousgetViewModelStore()function. ( I86409 , b/240298691 ) - The Kotlin extension on
LifecycleOwnerthat provides thelifecycleScopefield has been moved to thelifecycle-commonartifact fromlifecycle-runtime-ktx. ( I41d78 , b/240298691 ) - The Kotlin extension on
Lifecyclethat provides thecoroutineScopefield has been moved to thelifecycle-commonartifact fromlifecycle-runtime-ktx. ( Iabb91 , b/240298691 )
Version 2.6.0-alpha05
২৫ জানুয়ারী, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0-alpha05 is released. Version 2.6.0-alpha05 contains these commits.
Kotlin Conversions
-
Transformationsis now written in Kotlin. This is a source incompatible change for those classes written in Kotlin that were directly using syntax such asTransformations.map- Kotlin code must now use the Kotlin extension method syntax that was previously only available when usinglifecycle-livedata-ktx. When using the Java programming language, the versions of these methods that take anandroidx.arch.core.util.Functionmethod are deprecated and replaced with the versions that take a KotlinFunction1. This change maintains binary compatibility. ( I8e14f ) -
ViewTreeViewModelStoreOwneris now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now directly import and use the Kotlin extension methods onViewofandroidx.lifecycle.setViewTreeViewModelStoreOwnerandandroidx.lifecycle.findViewTreeViewModelStoreOwnerto set and find a previously set owner. This is binary compatible and remains source compatible for implementations written in the Java programming language. ( Ia06d8 , Ib22d8 , b/240298691 ) - The
HasDefaultViewModelProviderFactoryinterface is now written in Kotlin. This is a source incompatible change for classes written in Kotlin - they must now override thedefaultViewModelProviderFactoryanddefaultViewModelCreationExtrasproperties rather than implementing the previous corresponding functions. ( Iaed9c , b/240298691 ) -
Observeris now written in Kotlin. ItsonChanged()method now uses the namevaluefor its parameter. ( Iffef2 , I4995e , b/240298691 ) -
AndroidViewModel,AbstractSavedStateViewModelFactory,LifecycleService,ServiceLifecycleDispatcher, andProcessLifecycleOwnerare now written in Kotlin ( I2e771 , Ibae40 , I160d7 , I08884 , I1cda7 , b/240298691 )
Version 2.6.0-alpha04
১১ জানুয়ারী, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0-alpha04 is released. Version 2.6.0-alpha04 contains these commits.
নতুন বৈশিষ্ট্য
-
LiveDatanow includes a newisInitializedproperty that indicates whether an explicit value has ever been set on theLiveData, allowing you to distinguish betweenliveData.valuereturningnullbecause no value has ever been set or an explicitnullvalue. ( Ibd018 )
API Changes
- The
collectAsStateWithLifecycle()APIs oflifecycle-runtime-composeare no longer in experimental status. ( I09d42 , b/258835424 ) -
Lifecycle.launchWhenXmethods andLifecycle.whenXmethods have been deprecated as the use of a pausing dispatcher can lead to wasted resources in some cases. It is recommended to useLifecycle.repeatOnLifecycle. ( Iafc54 , b/248302832 )
Kotlin Conversions
-
ViewTreeLifecycleOwneris now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now directly import and use the Kotlin extension methods onViewofandroidx.lifecycle.setViewTreeLifecycleOwnerandandroidx.lifecycle.findViewTreeLifecycleOwnerto set and find a previously set owner. This replaces the previous Kotlin extension inlifecycle-runtime-ktx. This is binary compatible and remains source compatible for implementations written in the Java programming language. ( I8a77a , I5234e , b/240298691 ) -
LiveDataReactiveStreamsis now written in Kotlin. The Kotlin extensions previously inlifecycle-reactivestreams-ktxhave been moved into thelifecycle-reactivestreamsmodule and have become the primary surface for code written in Kotlin. This is a source incompatible change for code written in Kotlin if you were not already using the Kotlin extension method APIs. ( I2b1b9 , I95d22 , b/240298691 ) -
DefaultLifecycleObserver,LifecycleEventObserver,Lifecycle,LifecycleRegistry,LifecycleObserver, andViewModelStoreare now written in Kotlin ( Iadffd , ( I60034 , I8c52c , I9593d , I01fe1 , I59a23 , b/240298691 )
Bug Fixes
-
SavedStateHandleno longer crashes with aClassCastExceptionwhen callingget()with the incorrect class type. ( I6ae7c )
Version 2.6.0-alpha03
October 24, 2022
androidx.lifecycle:lifecycle-*:2.6.0-alpha03 is released. Version 2.6.0-alpha03 contains these commits.
Bug Fixes
- Fixed an issue with constraints between different Lifecycle modules not working as intended. ( I18d0d , b/249686765 )
- Errors thrown by
LifecycleRegistry.moveToState()now include a more helpful error messaging that informs developers of the component causing the error. ( Idf4b2 , b/244910446 )
Version 2.6.0-alpha02
৭ সেপ্টেম্বর, ২০২২
androidx.lifecycle:lifecycle-*:2.6.0-alpha02 is released. Version 2.6.0-alpha02 contains these commits.
API Changes
-
MediatorLiveDatanow includes a constructor to set an initial value. ( Ib6cc5 , b/151244085 )
Bug Fixes
-
Lifecycleartifacts now include constraints that ensure that all inter-dependent Lifecycle artifacts use the same version, automatically upgrading other dependencies when one is upgraded. b/242871265 -
FlowLiveData.asFlow()now creates acallbackFlowrather than using its ownChannelimplementation to ensure thread-safety and context preservation. ( I4a8b2 , b/200596935 ) -
FlowLiveData'sasLiveDatafunction will now preserve the initial value of aStateFlowwhen creating the newLiveDataobject. ( I3f530 , b/157380488 ) - From Lifecycle
2.5.1: Custom implementations ofAndroidViewModelFactorynow correctly calls thecreate(modelClass)function when using the stateful constructor withLifecycle2.4+ ( I5b315 , b/238011621 )
Version 2.6.0-alpha01
২৯ জুন, ২০২২
androidx.lifecycle:lifecycle-*:2.6.0-alpha01 is released. Version 2.6.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
- Added a new extension on
StateFlowandFlowofcollectAsStateWithLifecyclethat collect from flows and represents its latest value as Compose State in a lifecycle-aware manner. The flow is collected and the new emission is set to the State's value when the lifecycle is at least in a certainLifecycle.State. When the lifecycle falls below thatLifecycle.State, the flow collection stops and the State's value is not updated. ( I1856e , b/230557927 )
Version 2.5
Version 2.5.1
২৭ জুলাই, ২০২২
androidx.lifecycle:lifecycle-*:2.5.1 is released. Version 2.5.1 contains these commits.
Bug Fixes
- Custom implementations of
AndroidViewModelFactorynow correctly call thecreate(modelClass)function when using the statefulAndroidViewModelFactoryconstructor withLifecycle2.4+. ( I5b315 , b/238011621 )
সংস্করণ 2.5.0
২৯ জুন, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0 is released. Version 2.5.0 contains these commits.
Important changes since 2.4.0
SavedStateHandlenow offers agetStateFlow()API that returns a KotlinStateFlowfor monitoring value changes as an alternative to usingLiveData.ViewModel CreationExtras - when writing a custom
ViewModelProvider.Factory, it is no longer required to extendAndroidViewModelFactoryorAbstractSavedStateViewModelFactoryto gain access to anApplicationorSavedStateHandle, respectively. Instead, these fields are provided to everyViewModelProvider.Factorysubclass asCreationExtrasvia the new overload ofcreate:create(Class<T>, CreationExtras). These extras are provided automatically by your Activity or Fragment when using Activity1.5.0and Fragment1.5.0, respectively.class CustomFactory : ViewModelProvider.Factory { override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T { return when (modelClass) { HomeViewModel::class -> { // Get the Application object from extras val application = checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY]) // Pass it directly to HomeViewModel HomeViewModel(application) } DetailViewModel::class -> { // Create a SavedStateHandle for this ViewModel from extras val savedStateHandle = extras.createSavedStateHandle() DetailViewModel(savedStateHandle) } else -> throw IllegalArgumentException("Unknown class $modelClass") } as T } }lifecycle-viewmodelnow provides aviewModelFactoryKotlin DSL that allows you define yourViewModelProvider.Factoryin terms of one or more lambda initializers, one for each particularViewModelclass your custom factory supports, usingCreationExtrasas the primary data source.val customFactory = viewModelFactory { // The return type of the lambda automatically sets what class this lambda handles initializer { // Get the Application object from extras provided to the lambda val application = checkNotNull(get(ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY)) HomeViewModel(application) } initializer { val savedStateHandle = createSavedStateHandle() DetailViewModel(savedStateHandle) } }lifecycle-viewmodel-composenow offers aviewModel()API that takes a lambda factory for creating aViewModelinstance without requiring the creation of a customViewModelProvider.Factory.// Within a @Composable, you can now skip writing a custom Factory // and instead write a lambda to do the initialization of your ViewModel val detailViewModel = viewModel { // This lambda is only called the first time the ViewModel is created // and all CreationExtras are available inside the lambda val savedStateHandle = createSavedStateHandle() DetailViewModel(savedStateHandle) }SavedStateHandle Compose Saver Integration - the
lifecycle-viewmodel-composeartifact now contains new experimental APIs inSavedStateHandle.saveablethat allowrememberSaveablelike behavior backed by theSavedStateHandleof a `ViewModel.class ListScreenViewModel(handle: SavedStateHandle): ViewModel() { // This value survives both configuration changes and process death and recreation val editMode by handle.saveable { mutableStateOf(false) } }Added an
addCloseable()API and a new constructor overload that allow you to add one or moreCloseableobjects to theViewModelthat will be closed when theViewModelis cleared without requiring any manual work inonCleared().For instance, to create a coroutine scope that you can inject into a ViewModel, but control via testing, you can create a
CoroutineScopethat implementsCloseable:class CloseableCoroutineScope( context: CoroutineContext = SupervisorJob() + Dispatchers.Main.immediate ) : Closeable, CoroutineScope { override val coroutineContext: CoroutineContext = context override fun close() { coroutineContext.cancel() } }Which can then be used in your
ViewModelconstructor while maintaining the same lifetime asviewModelScope:class TestScopeViewModel( val customScope: CloseableCoroutineScope = CloseableCoroutineScope() ) : ViewModel(customScope) { // You can now use customScope in the same way as viewModelScope }
আচরণগত পরিবর্তন
- Attempting to move the
Lifecycle.StatefromINITIALIZEDtoDESTROYEDwill now always throw anIllegalStateExceptionregardless of whether theLifecyclehas an attached observer. -
LifecycleRegistrywill now clear their observers when they reach theDESTROYEDstate.
Version 2.5.0-rc02
June 15, 2022
androidx.lifecycle:lifecycle-*:2.5.0-rc02 is released. Version 2.5.0-rc02 contains these commits.
Bug Fixes
-
ViewModelProviderwill no longer crash when mixing previous versions of compileOnly Lifecycle dependencies with versions 2.5+. ( I81a66 , b/230454566 )
Version 2.5.0-rc01
১১ মে, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-rc01 is released. Version 2.5.0-rc01 contains these commits.
Bug Fixes
-
MediatorLiveData.addSource()now throws aNullPointerExceptionwhen passed anullsource instead of propagating thenullsource to observers.( Ibd0fb , b/123085232 )
Version 2.5.0-beta01
April 20, 2022
androidx.lifecycle:lifecycle-*:2.5.0-beta01 is released. Version 2.5.0-beta01 contains these commits.
API Changes
- Added
SavedStateHandle.saveableproperty delegates to use property names as keys for persisting state into theSavedStateHandle( I8bb86 , b/225014345 )
Bug Fixes
- Fixed an issue where nesting one
NavHostwithin anotherNavHostin a non-primary bottom navigation tab would lead to anIllegalStateExceptionwhen using multiple back stacks. ( I11bd5 , b/228865698 )
Version 2.5.0-alpha06
৬ এপ্রিল, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha06 is released. Version 2.5.0-alpha06 contains these commits.
নতুন বৈশিষ্ট্য
- Add experimental
MutableStateoverload toSavedStateHandle.saveablefor parity withrememberSaveable( I38cfe , b/224565154 )
API Changes
-
CreationExtrasis now abstract instead of sealed. ( Ib8a7a )
Bug Fixes
- Fixed an
IllegalStateException: Already attached to lifecycleOwnererror caused bySavedStateHandleController. ( I7ea47 , b/215406268 )
Version 2.5.0-alpha05
২৩ মার্চ, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha05 is released. Version 2.5.0-alpha05 contains these commits.
নতুন বৈশিষ্ট্য
- The
lifecycle-viewmodel-composemodule now providesSavedStateHandleSaver, an experimental API that ensures values in aSavedStateHandleare integrated correctly with the same saved instance state thatrememberSaveableuses. ( Ia88b7 , b/195689777 )
API Changes
- Fixed a compatibility issue with Lifecycle 2.3 and newer Lifecycle versions in Java. ( I52c8a , b/219545060 )
Bug Fixes
-
SavedStateViewFactorynow supports usingCreationExtraseven when it was initialized with aSavedStateRegistryOwner. If extras are provided, the initialized arguments are ignored. ( I6c43b , b/224844583 )
Version 2.5.0-alpha04
March 9, 2022
androidx.lifecycle:lifecycle-*:2.5.0-alpha04 is released. Version 2.5.0-alpha04 contains these commits.
API Changes
-
SavedStateHandlenow offers agetStateFlow()API that returns a KotlinStateFlowfor monitoring value changes as an alternative to usingLiveData. ( Iad3ab , b/178037961 )
Version 2.5.0-alpha03
February 23, 2022
androidx.lifecycle:lifecycle-*:2.5.0-alpha03 is released. Version 2.5.0-alpha03 contains these commits.
নতুন বৈশিষ্ট্য
- Added an
addCloseable()API and a new constructor overload that allow you to add one or moreCloseableobjects to theViewModelthat will be closed when theViewModelis cleared without requiring any manual work inonCleared(). ( I55ea0 ) -
lifecycle-viewmodelnow provides anInitializerViewModelFactorythat allows you to add lambda for handling particularViewModelclasses, usingCreationExtrasas the primary data source. ( If58fc , b/216687549 ) -
lifecycle-viewmodel-composenow offers aviewModel()API that takes a lambda factory for creating aViewModelinstance without requiring the creation of a customViewModelProvider.Factory. ( I97fbb , b/216688927 )
API Changes
- You can now create a
ViewModelwithCreationExtrasvialifecycle-viewmodel-compose. ( I08887 , b/216688927 )
আচরণগত পরিবর্তন
- Attempting to move the
Lifecycle.StatefromINITIALIZEDtoDESTROYEDwill now always throw anIllegalStateExceptionregardless of whether theLifecyclehas an attached observer. ( I7c390 , b/177924329 ) -
LifecycleRegistrywill now clear their observers when they reach theDESTROYEDstate. ( I4f8dd , b/142925860 )
Version 2.5.0-alpha02
৯ ফেব্রুয়ারী, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha02 is released. Version 2.5.0-alpha02 contains these commits.
API Changes
-
SavedStateHandleandSavedStateViewModelFactoryhave been converted to Kotlin. This has improved the nullability of the generics in both classes. ( Ib6ce2 , b/216168263 , I9647a , b/177667711 ) - The
LiveDataswitchMapfunction parameter can now have a nullable output. ( I40396 , b/132923666 ) - The
LiveData-ktx extensions are now annotated with@CheckResultto enforce that the result is used when calling these functions. ( Ia0f05 , b/207325134 )
আচরণগত পরিবর্তন
-
SavedStateHandlenow properly stores the defaultValue when no value for the specified key exists. ( I1c6ce , b/178510877 )
Bug Fixes
- From Lifecycle
2.4.1: Updatedlifecycle-processto depend on Startup 1.1.1 to ensure that fixes that preventProcessLifecycleInitializerfrom throwing aStartupExceptionare available by default. ( Ib01df , b/216490724 ) - There is now an improved error message when custom
AndroidViewModelclasses have parameters in the wrong order and attempt to create aViewModel. ( I340f7 , b/177667711 ) - You can now create a view model via
CreationExtrasusing theAndroidViewModelFactorywithout setting an application. ( I6ebef , b/217271656 )
Version 2.5.0-alpha01
২৬ জানুয়ারী, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha01 is released. Version 2.5.0-alpha01 contains these commits.
ViewModel CreationExtras
With this release, we are laying the groundwork for restructuring how a ViewModel is constructed. Instead of a rigid set of subclasses of ViewModelProvider.Factory that each add additional functionality (allowing an Application constructor parameter via AndroidViewModelFactory , allowing a SavedStateHandle constructor parameter via SavedStateViewModelFactory and AbstractSavedStateViewModelFactory , etc.), we are moving to a world of stateless factories that rely on a new concept, CreationExtras . ( Ia7343 , b/188691010 , b/188541057 )
With this change, ViewModelProvider no longer makes direct calls into the previous create(Class<T>) method of ViewModelProvider.Factory . Instead, it calls into a new overload of create : create(Class<T>, CreationExtras) . This means that any direct implementation of the ViewModelProvider.Factory instance now has access to each of these new CreationExtras :
-
ViewModelProvider.NewInstanceFactory.VIEW_MODEL_KEY: thisStringprovides access to the custom key you passed toViewModelProvider.get(). -
ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEYprovides access to theApplicationclass. -
SavedStateHandleSupport.SAVED_STATE_REGISTRY_OWNER_KEYprovides access to theSavedStateRegistryOwnerthat is being used to construct this ViewModel. -
SavedStateHandleSupport.VIEW_MODEL_STORE_OWNER_KEYprovides access to theViewModelStoreOwnerthat is being used to construct this ViewModel. -
SavedStateHandleSupport.DEFAULT_ARGS_KEYprovides access to theBundleof arguments that should be used to construct aSavedStateHandle.
These extras are provided by default when using Activity 1.5.0-alpha01 , Fragment 1.5.0-alpha01 , and Navigation 2.5.0-alpha01 . If you use an earlier version of those libraries, your CreationExtras will be empty - all of the existing subclasses of ViewModelProvider.Factory have been rewritten to support both the legacy creation path used by earlier versions of those libraries and the CreationExtras path which will be used going forward.
These CreationExtras allow you to construct a ViewModelProvider.Factory that passes just the information you need to each ViewModel without relying on a strict hierarchy of Factory subclasses:
class CustomFactory : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T {
return when (modelClass) {
HomeViewModel::class -> {
// Get the Application object from extras
val application = checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY])
// Pass it directly to HomeViewModel
HomeViewModel(application)
}
DetailViewModel::class -> {
// Create a SavedStateHandle for this ViewModel from extras
val savedStateHandle = extras.createSavedStateHandle()
DetailViewModel(savedStateHandle)
}
else -> throw IllegalArgumentException("Unknown class $modelClass")
} as T
}
}
We use the createSavedStateHandle() Kotlin extension function on CreationExtras from SavedStateHandleSupport to construct a SavedStateHandle only for the one ViewModel that needs it. ( Ia6654 , b/188541057 )
Custom CreationExtras can be provided by overriding getDefaultViewModelCreationExtras() in your ComponentActivity or Fragment , thus making them available to your custom ViewModelProvider.Factory as a built in form of assisted injection. These extras will automatically be made available to your custom Factory when used directly with ViewModelProvider or when using the by viewModels() and by activityViewModels() Kotlin property extensions. ( I79f2b , b/207012584 , b/207012585 , b/207012490 )
Bug Fixes
- Fixed an issue where the default value provided to a
SavedStateHandlewould reappear after process death and recreation, even if it was specifically removed from theSavedStateHandle. As a consequence of this,SavedStateHandlewill no longer merge default values and restored values together, instead only using the restored values as the source of truth. ( I53a4b )
Version 2.4
Version 2.4.1
৯ ফেব্রুয়ারী, ২০২২
androidx.lifecycle:lifecycle-*:2.4.1 is released. Version 2.4.1 contains these commits.
Bug Fixes
- Backported from Lifecycle
2.5.0-alpha01: Fixed an issue where the default value provided to aSavedStateHandlewould re-appear after process death and recreation, even if it was specifically removed from theSavedStateHandle. As a consequence of this,SavedStateHandlewill no longer merge default values and restored values together, instead only using the restored values as the source of truth. ( I53a4b ) -
lifecycle-processnow depends on Androidx Startup 1.1.1 which fixed a regression in where usingProcessLifecycleInitializerwould cause anStartupException. ( b/216490724 )
সংস্করণ 2.4.0
২৭ অক্টোবর, ২০২১
androidx.lifecycle:lifecycle-*:2.4.0 is released. Version 2.4.0 contains these commits.
Important changes since 2.3.0
-
@OnLifecycleEventwas deprecated.LifecycleEventObserverorDefaultLifecycleObservershould be used instead. -
androidx.lifecycle:lifecycle-viewmodel-composelibrary was added. It providesviewModel()composable andLocalViewModelStoreOwner.- Source-breaking change :
ViewModelProviderhas been rewritten in Kotlin.ViewModelProvider.Factory.createmethod no longer allows nullable generic.
- Source-breaking change :
- New coroutines API were added to
androidx.lifecycle:lifecycle-runtime-ktx: -
Lifecycle.repeatOnLifecycle, API that executes a block of code in a coroutine when the Lifecycle is at least in a certain state. The block will cancel and re-launch as the lifecycle moves in and out of the target state; -
Flow.flowWithLifecycle, API that emits values from the upstream Flow when the lifecycle is at least in a certain state. -
DefaultLifecycleObserverwas moved fromlifecycle.lifecycle-common-java8tolifecycle.lifecycle-common.lifecycle.lifecycle-common-java8doesn't provide anymore any additional functionality on top oflifecycle.lifecycle-common, so dependency on it can be replaced bylifecycle.lifecycle-common. - Non coroutines API from
lifecycle-viewmodel-ktxhave been moved to thelifecycle-viewmodelmodule. lifecycle-processnow usesandroidx.startupto initialize theProcessLifecycleOwner.Previously, this was being done by
androidx.lifecycle.ProcessLifecycleOwnerInitializer.If you used
tools:node="remove"theContentProviderbeing used to initialize process lifecycle in the past, then you need to do the following instead.<provider android:name="androidx.startup.InitializationProvider" android:authorities=\"${applicationId}.androidx-startup" android:exported="false" tools:node=\"merge"> <!-- If you are using androidx.startup to initialize other components --> <meta-data android:name="androidx.lifecycle.ProcessLifecycleInitializer" android:value="androidx.startup" tools:node="remove" /> </provider>(অথবা)
<!-- If you want to disable androidx.startup completely. --> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" tools:node="remove"> </provider>
Version 2.4.0-rc01
September 29, 2021
androidx.lifecycle:lifecycle-*:2.4.0-rc01 is released with no changes from Lifecycle 2.4.0-beta01. Version 2.4.0-rc01 contains these commits.
Version 2.4.0-beta01
১৫ সেপ্টেম্বর, ২০২১
androidx.lifecycle:lifecycle-*:2.4.0-beta01 is released. Version 2.4.0-beta01 contains these commits.
API Changes
-
@OnLifecycleEventwas deprecated.LifecycleEventObserverorDefaultLifecycleObservershould be used instead. ( I5a8fa ) - DefaultLifecycleObserver was moved from
androidx.lifecycle.lifecycle-common-java8toandroidx.lifecycle.lifecycle-common.androidx.lifecycle.lifecycle-common-java8doesn't provide anymore any additional functionality on top ofandroidx.lifecycle.lifecycle-common, so dependency on it can be replaced byandroidx.lifecycle.lifecycle-common. ( I021aa ) - Non coroutines API from
lifecycle-viewmodel-ktxhave been moved to thelifecycle-viewmodelmodule. ( I6d5b2 )
External Contribution
Version 2.4.0-alpha03
August 4, 2021
androidx.lifecycle:lifecycle-*:2.4.0-alpha03 is released. Version 2.4.0-alpha03 contains these commits.
API Changes
- Source-breaking change : ViewModelProvider has been rewritten in Kotlin.
ViewModelProvider.Factory.createmethod no longer allows nullable generic. ( I9b9f6 )
আচরণগত পরিবর্তন
- The
Lifecycle.repeatOnLifecycle:blockis now always invoked serially when repeating execution. ( Ibab33 )
External Contribution
- Thanks chao2zhang for fixing the code snippets in the
repeatOnLifecycledocumentation. #205 .
Version 2.4.0-alpha02
June 16, 2021
androidx.lifecycle:lifecycle-*:2.4.0-alpha02 is released. Version 2.4.0-alpha02 contains these commits.
নতুন বৈশিষ্ট্য
- Added a new
RepeatOnLifecycleWrongUsagelint check tolifecycle-runtime-ktxthat detects whenrepeateOnLifecycleis incorrectly used inonStart()oronResume(). ( 706078 , b/187887400 )
API Changes
- The
LifecycleOwner.addRepeatingJobAPI is removed in favor ofLifecycle.repeatOnLifecyclethat respects structured concurrency and is easier to reason about. ( I4a3a8 ) - Make
ProcessLifecycleInitializerpublic so otherandroidx.startup.Initializers can use these as dependencies. ( I94c31 )
Bug Fixes
- Fixed an issue with the
NullSafeMutableLiveDatalint check when the field has modifiers. ( #147 , b/183696616 ) - Fixed another issue with the
NullSafeMutableLiveDatalint check when using generics. ( #161 , b/184830263 )
External Contribution
- Thanks maxsav for improving the
NullSafeMutableLiveDatalint check. ( #147 , b/183696616 ) - Thanks kozaxinan for improving the
NullSafeMutableLiveDatalint check. ( #161 , b/184830263 )
Version 2.4.0-alpha01
২৪ মার্চ, ২০২১
androidx.lifecycle:lifecycle-*:2.4.0-alpha01 is released. Version 2.4.0-alpha01 contains these commits.
আচরণগত পরিবর্তন
lifecycle-processnow usesandroidx.startupto initialize theProcessLifecycleOwner.Previously, this was being done by
androidx.lifecycle.ProcessLifecycleOwnerInitializer.If you used
tools:node="remove"theContentProviderbeing used to initialize process lifecycle in the past, then you need to do the following instead.<provider android:name="androidx.startup.InitializationProvider" android:authorities=\"${applicationId}.androidx-startup" android:exported="false" tools:node=\"merge"> <!-- If you are using androidx.startup to initialize other components --> <meta-data android:name="androidx.lifecycle.ProcessLifecycleInitializer" android:value="androidx.startup" tools:node="remove" /> </provider>(অথবা)
<!-- If you want to disable androidx.startup completely. --> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" tools:node="remove"> </provider>
API Changes
- Added a
Flow.flowWithLifecycleAPI that emits values from the upstream Flow when the lifecycle is at least in a certain state using theLifecycle.repeatOnLifecycleAPI. This is an alternative to the also newLifecycleOwner.addRepeatinJobAPI. ( I0f4cd )
Bug Fixes
- From Lifecycle 2.3.1 : The
NonNullableMutableLiveDatalint rule can now properly differentiate between field variables with different nullability. ( b/169249668 )
Lifecycle Viewmodel Compose Version 1.0.0
Version 1.0.0-alpha07
June 16, 2021
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07 is released. Version 1.0.0-alpha07 contains these commits.
Breaking API Changes
-
viewModel()now takes an optionalViewModelStoreOwner, making it easier to work with owners other than theLocalViewModelStoreOwner. For example, you can now useviewModel(navBackStackEntry)to retrieve a ViewModel associated with a particular navigation graph. ( I2628d , b/188693123 )
Version 1.0.0-alpha06
June 2, 2021
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha06 is released. Version 1.0.0-alpha06 contains these commits.
Updated to be compatible with Compose version 1.0.0-beta08 .
Version 1.0.0-alpha05
১৮ মে, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05 is released. Version 1.0.0-alpha05 contains these commits.
নতুন বৈশিষ্ট্য
- Updated to be compatible with Compose version
1.0.0-beta07.
Bug Fixes
- The AndroidManifest files from ui-test-manifest and ui-tooling-data are now compatible with Android 12 ( I6f9de , b/184718994 )
Version 1.0.0-alpha04
৭ এপ্রিল, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.
Dependency Changes
- This version allows
androidx.hilt:hilt-navigation-composeandandroidx.navigation:navigation-composeto sync dependencies onandroidx.compose.compiler:compiler:1.0.0-beta04andandroidx.compose.runtime:runtime:1.0.0-beta04. For 1.0.0, it is required that the compiler and runtime match.
Version 1.0.0-alpha03
১০ মার্চ, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.
API Changes
-
LocalViewModelStoreOwner.currentnow returns a nullableViewModelStoreOwnerto better determine whether aViewModelStoreOwneris available in the current composition. APIs that require aViewModelStoreOwner, such asviewModel()andNavHost, still throw an exception if aViewModelStoreOwneris not set. ( Idf39a )
Lifecycle-Viewmodel-Compose Version 1.0.0-alpha02
২৪ ফেব্রুয়ারী, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.
API Changes
-
LocalViewModelStoreOwnernow has aprovidesfunctions that can be used withCompositionLocalProvider, replacing theasProvidableCompositionLocal()API. ( I45d24 )
Lifecycle-Viewmodel-Compose Version 1.0.0-alpha01
১০ ফেব্রুয়ারী, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha01 is released. Version 1.0.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
- The
viewModel()composable andLocalViewModelStoreOwnerwere moved fromandroidx.compose.ui.viewinteropto this artifact in theandroidx.lifecycle.viewmodel.composepackage. ( I7a374 )
সংস্করণ 2.3.1
Lifecycle Version 2.3.1
২৪ মার্চ, ২০২১
androidx.lifecycle:lifecycle-*:2.3.1 is released. Version 2.3.1 contains these commits.
Bug Fixes
- The
NonNullableMutableLiveDatalint rule can now properly differentiate between field variables with different nullability. ( b/169249668 )
সংস্করণ 2.3.0
সংস্করণ 2.3.0
১০ ফেব্রুয়ারী, ২০২১
androidx.lifecycle:lifecycle-*:2.3.0 is released. Version 2.3.0 contains these commits.
Major changes since 2.2.0
-
SavedStateHandlesupport for non-parcelable classes :SavedStateHandlenow supports lazy serialization by allowing you to callsetSavedStateProvider()for a given key, providing aSavedStateProviderthat will get a callback tosaveState()when theSavedStateHandleis asked to save its state. See Saving non-parcelable classes . - Lifecycle Behavior Enforcement :
- LifecycleRegistry now enforces
DESTROYEDas a terminal state. -
LifecycleRegistrynow verifies that its methods are called on main thread. It was always a requirement for lifecycles of activities, fragments etc. An addition of observers from non-main threads resulted in hard to catch crashes in runtime. ForLifecycleRegistryobjects that owned by your own components, you can explicitly opt out from checks by usingLifecycleRegistry.createUnsafe(...), but then you have to ensure that a proper synchronization is in place when thisLifecycleRegistryis accessed from different threads.
- LifecycleRegistry now enforces
- Lifecycle State and Event Helpers : Added static helper methods of
downFrom(State),downTo(State),upFrom(State),upTo(State)toLifecycle.Eventfor generating theEventgiven aStateand transition direction. Added thegetTargetState()method that provides theStatethat the Lifecycle will transition to directly following theEvent. -
withStateAtLeast: AddedLifecycle.withStateAtLeastAPIs that await a lifecycle state and run a non-suspending block of code synchronously at the point of state change, then resume with the result. These APIs differ from the existingwhen*methods as they do not permit running suspending code and do not employ a custom dispatcher. ( aosp/1326081 ) -
ViewTreeAPIs : A newViewTreeLifecycleOwner.get(View)andViewTreeViewModelStoreOwner.get(View)API allows you to retrieve the containingLifecycleOwnerandViewModelStoreOwner, respectively, given aViewinstance. You must upgrade to Activity1.2.0and Fragment1.3.0, and AppCompat 1.3.0-alpha01 or higher to populate this correctly. ThefindViewTreeLifecycleOwnerandfindViewTreeViewModelStoreOwnerKotlin extensions are available inlifecycle-runtime-ktxandlifecycle-viewmodel-ktx, respectively. -
LiveData.observe()Kotlin extension deprecation : TheLiveData.observe()Kotlin extension necessary to use lambda syntax is now deprecated as it is not necessary when using Kotlin 1.4.
Version 2.3.0-rc01
১৬ ডিসেম্বর, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-rc01 is released. Version 2.3.0-rc01 contains these commits.
Bug Fixes
- The
keys()method ofSavedStateHandleis now consistent before and after the state is saved - it now includes keys previously used withsetSavedStateProvider()in addition to the keys used withset()andgetLiveData(). ( aosp/1517919 , b/174713653 )
External Contribution
- The APIs to suspend Lifecycle-aware coroutines now better handle calls to
yield(). Thanks Nicklas Ansman Giertz! ( aosp/1430830 , b/168777346 )
Version 2.3.0-beta01
১ অক্টোবর, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-beta01 is released. Version 2.3.0-beta01 contains these commits.
API Changes
- The
LiveData.observe()Kotlin extension necessary to use lambda syntax is now deprecated as it is not necessary when using Kotlin 1.4. ( I40d3f )
Bug Fixes
- Upgrade androidx to use Kotlin 1.4 ( Id6471 , b/165307851 , b/165300826 )
Documentation Changes
- The
liveDatabuilder andasLiveData()docs have been updated to include details about changing the given timeout values. ( aosp/1122324 )
Version 2.3.0-alpha07
১৯ আগস্ট, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-alpha07 is released. Version 2.3.0-alpha07 contains these commits.
Bug Fixes
- Fixed a crash issue in the
NullSafeMutableLiveDataLint check. ( aosp/1395367 )
Version 2.3.0-alpha06
July 22, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha06 is released. Version 2.3.0-alpha06 contains these commits.
নতুন বৈশিষ্ট্য
- Added static helper methods of
downFrom(State),downTo(State),upFrom(State),upTo(State)toLifecycle.Eventfor generating theEventgiven aStateand transition direction. Added thegetTargetState()method that provides theStatethat the Lifecycle will transition to directly following theEvent. ( I00887 ) - Added
Lifecycle.withStateAtLeastAPIs that await a lifecycle state and run a non-suspending block of code synchronously at the point of state change, then resume with the result. These APIs differ from the existingwhen*methods as they do not permit running suspending code and do not employ a custom dispatcher. ( aosp/1326081 )
আচরণগত পরিবর্তন
- LifecycleRegistry now enforces
DESTROYEDas a terminal state. ( I00887 ) -
LifecycleRegistrynow verifies that its methods are called on main thread. It was always a requirement for lifecycles of activities, fragments etc. An addition of observers from non-main threads resulted in hard to catch crashes in runtime. ForLifecycleRegistryobjects that owned by your own components, you can explicitly opt out from checks by usingLifecycleRegistry.createUnsafe(...), but then you have to ensure that a proper synchronization is in place when thisLifecycleRegistryis accessed from different threads ( Ie7280 , b/137392809 )
Bug Fixes
- Fixed a crash in
NullSafeMutableLiveData. ( b/159987480 ) - Fixed an
ObsoleteLintCustomCheckfor Lint checks bundled withlifecycle-livedata-core-ktx(and specificallyNullSafeMutableLiveData). ( b/158699265 )
Version 2.3.0-alpha05
২৪ জুন, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-alpha05 is released. Version 2.3.0-alpha05 contains these commits.
Bug Fixes
-
LiveDatanow better handles reentrant cases, avoiding duplicate calls toonActive()oronInactive(). ( b/157840298 ) - Fixed an issue where Lint checks would not run when using Android Studio 4.1 Canary 6 or higher. ( aosp/1331903 )
Version 2.3.0-alpha04
June 10, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha04 is released. Version 2.3.0-alpha04 contains these commits.
Bug Fixes
- Fixed a crash in the
NonNullableMutableLiveDataLint check. ( b/157294666 ) - The
NonNullableMutableLiveDataLint check now covers significantly more cases where anullvalue was set on aMutableLiveDatawith a non-null type parameter. ( b/156002218 )
Version 2.3.0-alpha03
May 20, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha03 are released. Version 2.3.0-alpha03 contains these commits.
নতুন বৈশিষ্ট্য
-
SavedStateHandlenow supports lazy serialization by allowing you to callsetSavedStateProvider()for a given key, providing aSavedStateProviderthat will get a callback tosaveState()when theSavedStateHandleis asked to save its state. ( b/155106862 ) - A new
ViewTreeViewModelStoreOwner.get(View)API allows you to retrieve the containingViewModelStoreOwnergiven aViewinstance. You must upgrade to Activity1.2.0-alpha05, Fragment1.3.0-alpha05, and AppCompat1.3.0-alpha01to populate this correctly. AfindViewModelStoreOwner()Kotlin extension has been added tolifecycle-viewmodel-ktx. ( aosp/1295522 )
Bug Fixes
- Fixed an issue that caused the
MutableLiveDataLint checks released in Lifecycle2.3.0-alpha01from being published alongside thelifecycle-livedata-core-ktxartifact. ( b/155323109 )
Version 2.3.0-alpha02
২৯ এপ্রিল, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-alpha02 is released. Version 2.3.0-alpha02 contains these commits.
API Changes
-
SavedStateViewModelFactorynow allows you to pass a nullApplicationto its constructor to better support cases where one is not readily available and support forAndroidViewModelis not needed. ( aosp/1285740 )
Bug Fixes
- Improved cold start performance by avoiding class verification failure on API 28 and lower devices. ( aosp/1282118 )
Version 2.3.0-alpha01
March 4, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha01 is released. Version 2.3.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
- A new
ViewTreeLifecycleOwner.get(View)API allows you to retrieve the containingLifecycleOwnergiven aViewinstance. You must upgrade to Activity1.2.0-alpha01and Fragment1.3.0-alpha01to populate this correctly. AfindViewTreeLifecycleOwnerKotlin extension is available inlifecycle-runtime-ktx. ( aosp/1182361 , aosp/1182956 ) - Added a new Lint check that warns you when setting a
nullvalue on aMutableLiveDatathat has been defined in Kotlin as non-null. This is available when using thelivedata-core-ktxorlivedata-ktxartifacts. ( aosp/1154723 , aosp/1159092 ) - A new
lifecycle-runtime-testingartifact is available that provides aTestLifecycleOwnerthat implementsLifecycleOwnerand provides a thread safe mutableLifecycle. ( aosp/1242438 )
বাগ সংশোধন
- The
lifecycle-runtimeartifact now has a unique package name. ( aosp/1187196 )
সংস্করণ 2.2.0
ViewModel-Savedstate Version 2.2.0
৫ ফেব্রুয়ারী, ২০২০
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0 is released. Version 2.2.0 contains these commits .
Lifecycle ViewModel SavedState now shares the same version as other Lifecycle artifacts. The behavior of 2.2.0 is identical to the behavior of 1.0.0 .
সংস্করণ 2.2.0
২২ জানুয়ারী, ২০২০
androidx.lifecycle:lifecycle-*:2.2.0 is released. Version 2.2.0 contains these commits .
Important changes since 2.1.0
- Lifecycle Coroutine Integration : The new
lifecycle-runtime-ktxartifact adds integration between Lifecycle and Kotlin coroutines. Thelifecycle-livedata-ktxhas also been expanded to take advantage of coroutines. See Use Kotlin coroutines with Architecture Components for more details. -
ViewModelProviders.of()deprecation :ViewModelProviders.of()has been deprecated. You can pass aFragmentorFragmentActivityto the newViewModelProvider(ViewModelStoreOwner)constructor to achieve the same functionality when using Fragment1.2.0. -
lifecycle-extensionsArtifact Deprecation : With the above deprecation ofViewModelProviders.of(), this release marks the deprecation of the last API inlifecycle-extensionsand this artifact should now be considered deprecated in its entirety. We strongly recommend depending on the specific Lifecycle artifacts you need (such aslifecycle-serviceif you're usingLifecycleServiceandlifecycle-processif you're usingProcessLifecycleOwner) rather thanlifecycle-extensionsas there will not be a future2.3.0release oflifecycle-extensions. - Gradle Incremental Annotation Processor : Lifecycle's annotation processor is incremental by default. If your app is written in the Java 8 programming language you can use
DefautLifecycleObserverinstead; and if it's written in the Java 7 programming language you can useLifecycleEventObserver.
Version 2.2.0-rc03
৪ ডিসেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-rc03 is released. Version 2.2.0-rc03 contains these commits .
বাগ সংশোধন
- Fixed a failure occurring when a mocked
ViewModelwas stored inViewModelStoreand queried later with default factory. - Fix a usage of
Dispatchers.Main.immediateinlaunchWhenCreatedand similar methods to be called synchronously during corresponding lifecycle event. ( aosp/1156203 )
External contributions
- Thanks to Anders Järleberg for contributing the fix! ( aosp/1156203 )
- Thanks to Vsevolod Tolstopyatov from Jetbrains for reviewing an implementation of inlined execution.
Dependency changes
- Lifecycle Extensions now depends on Fragment
1.2.0-rc03.
Version 2.2.0-rc02
৭ নভেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-rc02 is released. Version 2.2.0-rc02 contains these commits .
বাগ সংশোধন
- Fixed a bug in the proguard setup of the library that affected devices running API 28+ if the target API is below 29. ( b/142778206 )
Version 2.2.0-rc01
২৩ অক্টোবর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-rc01 is released. Version 2.2.0-rc01 contains these commits .
বাগ সংশোধন
- Fixed an issue where
launchWhenCreatedand related methods would run one frame later than the associated lifecycle method due to its use ofDispatchers.Maininstead ofDispatchers.Main.immediate. ( aosp/1145596 )
External contributions
- Thanks to Nicklas Ansman for contributing the fix! ( aosp/1145596 )
Version 2.2.0-beta01
October 9, 2019
androidx.lifecycle:lifecycle-*:2.2.0-beta01 is released. Version 2.2.0-beta01 contains these commits .
বাগ সংশোধন
- Fixed a regression introduced in Lifecycle 2.2.0-alpha05 in the ordering of
ProcessLifecycleOwnerand the activity'sLifecycleOwnermoving to started and resumed on Android 10 devices. ( aosp/1128132 ) - Fixed a regression introduced in Lifecycle
2.2.0-alpha05which would cause aNullPointerExceptionwhen using version2.0.0or2.1.0oflifecycle-process. ( b/141536990 )
Version 2.2.0-alpha05
১৮ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-alpha05 is released. Version 2.2.0-alpha05 contains these commits .
বাগ সংশোধন
- Fixed a race condition in coroutine livedata builder. b/140249349
Version 2.2.0-alpha04
৫ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-alpha04 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
-
lifecycleScope,whenCreated,whenStarted,whenResumed,viewModelScope, and the underlying implementation ofliveDatanow useDispatchers.Main.immediateinstead ofDispatchers.Main. ( b/139740492 )
External contributions
- Thanks to Nicklas Ansman for contributing the move to
Dispatchers.Main.immediate! ( aosp/1106073 )
Version 2.2.0-alpha03
৭ আগস্ট, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-alpha03 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- Implementations of
ViewModelStoreOwnercan now optionally implementHasDefaultViewModelProviderFactoryto provide a defaultViewModelProvider.Factory. This has been done for Activity1.1.0-alpha02, Fragment1.2.0-alpha02, and Navigation2.2.0-alpha01. ( aosp/1092370 , b/135716331 )
API changes
-
ViewModelProviders.of()has been deprecated. You can pass aFragmentorFragmentActivityto the newViewModelProvider(ViewModelStoreOwner)constructor to achieve the same functionality. ( aosp/1009889 )
Version 2.2.0-alpha02
July 2, 2019
androidx.lifecycle:*:2.2.0-alpha02 is released. The commits included in this version can be found here .
API changes
- Replaced
LiveDataScope.initialValuewithLiveDataScope.latestValuewhich will track the current emitted value of theliveDatablock. - Added a new overload to the
liveDatabuilder that receivestimeoutparameter as typeDuration
Version 2.2.0-alpha01
৭ মে, ২০১৯
androidx.lifecycle:*:2.2.0-alpha01 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- This release adds new features that adds support for Kotlin coroutines for Lifecycle and LiveData. Detailed documentation on them can be found here .
ViewModel-SavedState Version 1.0.0
সংস্করণ 1.0.0
২২ জানুয়ারী, ২০২০
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0 is released. Version 1.0.0 contains these commits .
Important features in 1.0.0
- New SavedStateHandle class was added. It enables your
ViewModelclasses to access and to contribute to the saved state. This object can be received in constructor ofViewModelclass and factories provided by default by Fragments and AppCompatActivity will injectSavedStateHandleautomatically. - AbstractSavedStateViewModelFactory was added. It allows you to create custom factories for your
ViewModeland provide them access toSavedStateHandle.
ViewModel-Savedstate Version 1.0.0-rc03
৪ ডিসেম্বর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc03 is released. Version 1.0.0-rc03 contains these commits .
Dependency changes
- Lifecycle ViewModel SavedState now depends on Lifecycle
2.2.0-rc03.
Viewmodel-Savedstate Version 1.0.0-rc02
৭ নভেম্বর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc02 is released. Version 1.0.0-rc02 contains these commits .
Dependency changes
- Now depends on lifecycle
2.2.0-rc02.
ViewModel-SavedState Version 1.0.0-rc01
২৩ অক্টোবর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc01 is released with no changes from 1.0.0-beta01 . Version 1.0.0-rc01 contains these commits .
ViewModel-Savedstate Version 1.0.0-beta01
October 9, 2019
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-beta01 is released. Version 1.0.0-beta01 contains these commits .
বাগ সংশোধন
- Fixed an issue where accessing a SavedState ViewModel for the first time in
Activity.onActivityResult()would result in anIllegalStateException. ( b/139093676 ) - Fixed an
IllegalStateExceptionwhen usingAbstractSavedStateViewModelFactory. ( b/141225984 )
ViewModel-SavedState Version 1.0.0-alpha05
১৮ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha05 is released. Version 1.0.0-alpha05 contains these commits .
API changes
-
SavedStateViewModelFactoryno longer extendsAbstractSavedStateViewModelFactoryandSavedStateHandleis created only for ViewModels that requested have it ( aosp/1113593 )
ViewModel-SavedState Version 1.0.0-alpha03
৭ আগস্ট, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha03 is released. The commits included in this version can be found here .
Breaking Changes
-
lifecycle-viewmodel-savedstateno longer depends onfragmentand the relatedSavedStateViewModelFactory(Fragment)andSavedStateViewModelFactory(FragmentActivity)constructors have been removed. Instead,SavedStateViewModelFactoryis now the default factory for Activity1.1.0-alpha02, Fragment1.2.0-alpha02, and Navigation2.2.0-alpha01. ( b/135716331 )
ViewModel-SavedState Version 1.0.0-alpha02
July 2, 2019
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha02 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- Added
SavedStateHandle.getLiveData()overload which accepts a default value.
API Changes
-
SavedStateVMFactoryis renamed toSavedStateViewModelFactory. -
AbstractSavedStateVMFactoryis renamed toAbstractSavedStateViewModelFactory.
ViewModel-Savedstate Version 1.0.0-alpha01
March 13, 2019
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01 is released. The full commit log for this initial release can be found here .
নতুন বৈশিষ্ট্য
- Now
ViewModelscan contribute to savedstate. To do that you use newly introduced viewmodel's factorySavedStateVMFactoryand your ViewModel should have a constructor that receivesSavedStateHandleobject as a parameter.
সংস্করণ 2.1.0
Important changes since 2.0.0
- Added
LifecycleEventObserverfor the cases when a stream of lifecycle events is needed. It is a public API instead of a hiddenGenericLifecycleObserverclass. - Added ktx extensions for
LiveData.observemethods andTransformations.*methods. - Added
Transformations.distinctUntilChanged, which creates a new LiveData object that does not emit a value until the sourceLiveDatavalue has been changed. - Added coroutine support in ViewModels by adding the extension property
ViewModel.viewModelScope.
সংস্করণ 2.1.0
৫ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.1.0 is released. The commits included in this version can be found here .
Version 2.1.0-rc01
July 2, 2019
androidx.lifecycle:*:2.1.0-rc01 is released with no changes from androidx.lifecycle:*:2.1.0-beta01 . The commits included in this version can be found here .
Version 2.1.0-beta01
৭ মে, ২০১৯
androidx.lifecycle:*:2.1.0-beta01 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- Lifecycles are graduated to beta: api introduced in previous alphas such as
liveDataextension functions for transformations and observations,ViewModelinitialisation with property delegation and others are stabilised and not going to change.
Version 2.1.0-alpha04
April 3, 2019
androidx.lifecycle:*:2.1.0-alpha04 is released. The commits included in this version can be found here .
API changes
- Breaking change: the underlying API behind
by viewModels()andby activityViewModels()has been changed to support aViewModelStoredirectly, rather than only aViewModelStoreOwner. ( aosp/932932 )
Version 2.1.0-alpha03
March 13, 2019
androidx.lifecycle:*:2.1.0-alpha03 is released. The full list of commits included in this version can be found here .
API changes
-
ViewModelProvider.KeyedFactorywas removed. Second interface in addition toViewModelProvider.Factorydidn't compose well with new features as property delegation in Kotlinby viewmodels {}. ( aosp/914133 )
Version 2.1.0-alpha02
January 30, 2019
androidx.lifecycle 2.1.0-alpha02 is released.
API changes
-
LifecycleRegistrynow contains asetCurrentState()method that replaces the now deprecatedsetState()method. ( aosp/880715 )
বাগ সংশোধন
- Fixed an issue where mock
ViewModelinstances would crash when the containingViewModelStorewas cleared. b/122273087
Version 2.1.0-alpha01
১৭ ডিসেম্বর, ২০১৮
androidx.lifecycle 2.1.0-alpha01 is released.
নতুন বৈশিষ্ট্য
- Added
LifecycleEventObserverfor the cases when a stream of lifecycle events is needed. It is a public api instead of a hiddenGenericLifecycleObserverclass. - Added ktx extensions for
LiveData.observemethods andTransformations.*methods. - Method
Transformations.distinctUntilChangedwas added. It creates a newLiveDataobject that does not emit a value until the source LiveData value has been changed. - Coroutine support in ViewModels: extension property
ViewModel.viewModelScopewas added. - Added
ViewModelProvider.KeyedFactory, a factory for ViewModels that receiveskeyandClassincreatemethod.
সংস্করণ 2.0.0
সংস্করণ 2.0.0
September 21, 2018
Lifecycle 2.0.0 is released with one bugfix from 2.0.0-rc01 in ViewModel.
Bug Fixes
- Fixed a ViewModel proguard rule that incorrectly removed constructors b/112230489
Version 2.0.0-beta01
July 2, 2018
Bug Fixes
- Fixed LifecycleObserver proguard rule to keep only implementations, not subinterfaces b/71389427
- Fixed ViewModel proguard rules to allow obfuscation and shrinking
Pre-AndroidX Versions
For the pre-AndroidX versions of Lifecycle that follow, include these dependencies:
dependencies {
def lifecycle_version = "1.1.1"
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
// alternatively - just ViewModel
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version" // For Kotlin use viewmodel-ktx
// alternatively - just LiveData
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
// alternatively - Lifecycles only (no ViewModel or LiveData).
// Support library depends on this lightweight import
implementation "android.arch.lifecycle:runtime:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version" // For Kotlin use kapt instead of annotationProcessor
// alternately - if using Java8, use the following instead of compiler
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
// optional - ReactiveStreams support for LiveData
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
// optional - Test helpers for LiveData
testImplementation "android.arch.core:core-testing:$lifecycle_version"
}
Version 1.1.1
March 21, 2018
Only one small change: android.arch.core.util.Function is moved from arch:runtime to arch:common . This allows it to be used without the runtime dependency, eg in paging:common below.
lifecycle:common is a dependency of lifecycle:runtime , so this change doesn't affect lifecycle:runtime directly, only modules that depend directly on lifecycle:common , as Paging does.
সংস্করণ 1.1.0
January 22, 2018
Packaging Changes
New, much smaller dependencies are now available:
-
android.arch.lifecycle:livedata:1.1.0 -
android.arch.lifecycle:viewmodel:1.1.0
API Changes
- The deprecated
LifecycleActivityandLifecycleFragmenthave now been removed - please useFragmentActivity,AppCompatActivityor supportFragment. -
@NonNullannotations have been added toViewModelProvidersandViewModelStores -
ViewModelProvidersconstructor has been deprecated - please use its static methods directly -
ViewModelProviders.DefaultFactoryhas been deprecated - please useViewModelProvider.AndroidViewModelFactory - The static
ViewModelProvider.AndroidViewModelFactory.getInstance(Application)method has been added to retrieve a staticFactorysuitable for creatingViewModelandAndroidViewModelinstances.
Lifecycle
This table lists all the artifacts in the androidx.lifecycle group.
| শিল্পকর্ম | Stable Release | Release Candidate | Beta Release | Alpha Release |
|---|---|---|---|---|
| lifecycle-* | 2.9.4 | 2.10.0-rc01 | - | - |
| lifecycle-viewmodel-navigation3 | - | 2.10.0-rc01 | - | - |
Declaring dependencies
To add a dependency on Lifecycle, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle file for your app or module:
কোটলিন
গ্রোভি
dependencies { def lifecycle_version = "2.9.4" def arch_version = "2.2.0" // ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" // ViewModel utilities for Compose implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version" // LiveData implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" // Lifecycles only (without ViewModel or LiveData) implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" // Lifecycle utilities for Compose implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version" // Saved state module for ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" // ViewModel integration with Navigation3 implementation "androidx.lifecycle:lifecycle-viewmodel-navigation3:2.10.0-rc01" // Annotation processor kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // alternately - if using Java8, use the following instead of lifecycle-compiler implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" // optional - helpers for implementing LifecycleOwner in a Service implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version" // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version" // optional - ReactiveStreams support for LiveData implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version" // optional - Test helpers for LiveData testImplementation "androidx.arch.core:core-testing:$arch_version" // optional - Test helpers for Lifecycle runtime testImplementation "androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version" }
কোটলিন
dependencies { val lifecycle_version = "2.9.4" val arch_version = "2.2.0" // ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version") // ViewModel utilities for Compose implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version") // LiveData implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version") // Lifecycles only (without ViewModel or LiveData) implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version") // Lifecycle utilities for Compose implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version") // Saved state module for ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version") // ViewModel integration with Navigation3 implementation("androidx.lifecycle:lifecycle-viewmodel-navigation3:2.10.0-rc01") // Annotation processor kapt("androidx.lifecycle:lifecycle-compiler:$lifecycle_version") // alternately - if using Java8, use the following instead of lifecycle-compiler implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version") // optional - helpers for implementing LifecycleOwner in a Service implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version") // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation("androidx.lifecycle:lifecycle-process:$lifecycle_version") // optional - ReactiveStreams support for LiveData implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version") // optional - Test helpers for LiveData testImplementation("androidx.arch.core:core-testing:$arch_version") // optional - Test helpers for Lifecycle runtime testImplementation ("androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version") }
জাভা
গ্রোভি
dependencies { def lifecycle_version = "2.9.4" def arch_version = "2.2.0" // ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" // LiveData implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version" // Lifecycles only (without ViewModel or LiveData) implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version" // Saved state module for ViewModel implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" // Annotation processor annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" // alternately - if using Java8, use the following instead of lifecycle-compiler implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" // optional - helpers for implementing LifecycleOwner in a Service implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version" // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version" // optional - ReactiveStreams support for LiveData implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // optional - Test helpers for LiveData testImplementation "androidx.arch.core:core-testing:$arch_version" // optional - Test helpers for Lifecycle runtime testImplementation "androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version" }
কোটলিন
dependencies { val lifecycle_version = "2.9.4" val arch_version = "2.2.0" // ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version") // LiveData implementation("androidx.lifecycle:lifecycle-livedata:$lifecycle_version") // Lifecycles only (without ViewModel or LiveData) implementation("androidx.lifecycle:lifecycle-runtime:$lifecycle_version") // Saved state module for ViewModel implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version") // Annotation processor annotationProcessor("androidx.lifecycle:lifecycle-compiler:$lifecycle_version") // alternately - if using Java8, use the following instead of lifecycle-compiler implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version") // optional - helpers for implementing LifecycleOwner in a Service implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version") // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process implementation("androidx.lifecycle:lifecycle-process:$lifecycle_version") // optional - ReactiveStreams support for LiveData implementation("androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version") // optional - Test helpers for LiveData testImplementation("androidx.arch.core:core-testing:$arch_version") // optional - Test helpers for Lifecycle runtime testImplementation("androidx.lifecycle:lifecycle-runtime-testing:$lifecycle_version") }
For more information about dependencies, see Add Build Dependencies .
প্রতিক্রিয়া
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Version 2.10
Version 2.10.0-rc01
০৫ নভেম্বর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-rc01 is released. Version 2.10.0-rc01 contains these commits .
Version 2.10.0-beta01
২২ অক্টোবর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-beta01 is released. Version 2.10.0-beta01 contains these commits .
API Changes
-
ViewModelStoreNavEntryDecoratorDefaulthas been renamed toViewModelStoreNavEntryDecoratorDefaults, with an 's'. ( I6d27b , b/444447434 )
Bug Fixes
-
rememberLifecycleOwnerno longer crashes if the owner receives anLifecycle.Event.ON_DESTROYevent before moving toLifeycle.State.CREATED. ( I6f98e , b/444594991 )
Version 2.10.0-alpha05
October 08, 2025
androidx.lifecycle:lifecycle-*:2.10.0-alpha05 is released. Version 2.10.0-alpha05 contains these commits .
API Changes
- The
removeViewModelStoreOnPopCallback()is now part of aViewModelStoreNavEntryDecoratorDefaultobject which is where other platforms and implementations can call the default. ( Ia1f23 , b/444447434 ) - Refactored
ViewModelStoreNavEntryDecoratorfrom a function to a class to better reflect its functionality as a factory forNavEntryDecorator, and renamed the decorator'sshouldRemoveViewModelStoreparameter toremoveViewModelStoreOnPopto clarify that this callback is invoked only when an entry is popped from thebackStack. ( Iefdc5 , b/444447434 )
Version 2.10.0-alpha04
২৪ সেপ্টেম্বর, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha04 is released. Version 2.10.0-alpha04 contains these commits .
API Changes
- Refactor the
LifecycleOwnercomposable torememberLifecycleOwner. The function now returns theLifecycleOwnerdirectly. To provide this owner to a sub-composition, useCompositionLocalProvider. ( Ic57f0 , b/444446629 ) - Add KMP stubs to lifecycle-viewmodel-navigation3 to enable JetBrains to provide forks that fill these targets and thus support CMP. ( I44a4c )
Version 2.10.0-alpha03
২৭ আগস্ট, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha03 is released. Version 2.10.0-alpha03 contains these commits .
API Changes
- Update Compose to 1.9.0. ( I2b9de )
Version 2.10.0-alpha02
১৩ আগস্ট, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha02 is released. Version 2.10.0-alpha02 contains these commits .
নতুন বৈশিষ্ট্য
The
LifecycleOwnercomposable can now create a standalone root lifecycle . By (explicitly) settingparent = null, the new lifecycle operates independently of any host (like anActivity,FragmentorNavBackStackEntry). It starts as soon as the composable enters the composition and is automatically destroyed when it leaves. ( I8dfbe , b/433659048 )@Composable fun IndependentComponent() { // Create a standalone lifecycle, not tied to the parent Activity/Fragment. LifecycleOwner(parent = null) { val rootLifecycle = LocalLifecycleOwner.current.lifecycle } }
API Changes
- In the
LifecycleOwnercomposable, theparentLifecycleOwnerparameter has been renamed toparent. ( I080bc )
Bug Fixes
-
LifecycleOwnercomposable now correctly moves its lifecycle toDESTROYEDupon disposal. This prevents potential leaks for external code that holds a reference to the lifecycle. ( I9e5b7 , b/433659048 ) - Moving the default minSdk from API 21 to API 23 ( Ibdfca , b/380448311 , b/435705964 , b/435705223 )
External Contribution
- Remove unnecessary internal backing fields from
LifecycleOwner. Thanks Jake Wharton for the contribution. ( Ideddb )
Version 2.10.0-alpha01
৩০ জুলাই, ২০২৫
androidx.lifecycle:lifecycle-*:2.10.0-alpha01 is released. Version 2.10.0-alpha01 contains these commits .
নতুন বৈশিষ্ট্য
Add a
LifecycleOwnercomposable to enable creating scoped lifecycles directly within the UI. This is useful for components that need to manage their own lifecycles independently. For an example of how Navigation3 integrates this new composable, see aosp/3708610 . ( 76cbf7 )@Composable fun MyComposable() { LifecycleOwner( maxLifecycle = RESUMED, parentLifecycleOwner = LocalLifecycleOwner.current, ) { val childLifecycleOwner = LocalLifecycleOwner.current } }
API Changes
- Add a builder factory function for
CreationExtras, providing a more convenient and idiomatic Kotlin API. ( Iab2bd ) - Add native support for nullable types in
SavedStateHandle.saved, simplifying saving and restoring nullable properties. ( I54d69 , b/421325690 ) - Mark
SavedStateHandleconstructors as@VisibleForTesting. ( Iff0e0 , b/408002794 )
Version 2.9
Version 2.9.4
১৭ সেপ্টেম্বর, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.4 is released. Version 2.9.4 contains these commits .
Bug Fixes
- Fixed an error with the Compose Compiler plugin not being applied that caused Lifecycle KMP artifacts to be broken. ( Ie95bc , b/443096483 , b/443965665 )
Version 2.9.3
২৭ আগস্ট, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.3 is released. Version 2.9.3 contains these commits .
নতুন বৈশিষ্ট্য
- Add new Kotlin Multiplatform (KMP) targets to Lifecycle
*-composeartifacts. Lifecycle now supports the following platforms in total: JVM (Android and Desktop), Native (Linux, iOS, watchOS, macOS, MinGW), and Web (JavaScript, WasmJS). ( I0a0e4 )
Bug Fixes
- Update
androidx.annotationto 1.9.1 ( Ic9e4f , b/397701294 )
Version 2.9.2
১৬ জুলাই, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.2 is released. Version 2.9.2 contains these commits .
Bug Fixes
- Added new Kotlin Multiplatform (KMP) targets to Lifecycle artifacts. Lifecycle now supports the following platforms in total: JVM (Android and Desktop), Native (Linux, iOS, watchOS, macOS, MinGW), and Web (JavaScript, WasmJS). Note that no new KMP targets have been added to the
*-composeartifacts, as this depends on the stable release of Compose 1.9. ( I01cb8 ).
Dependency updates
- Lifecycle now depends on Annotation
1.9.1to enable support for the new KMP targets ( Ic9e4f , b/397701294 ).
Version 2.9.1
৪ জুন, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.1 is released. Version 2.9.1 contains these commits .
Bug Fixes
- Fix
SavedStateHandle.remove(key)not clearingSavedStateHandle.getMutableStateFlow(key)states. ( d5f939 , b/418746333 )
Version 2.9.0
May 7, 2025
androidx.lifecycle:lifecycle-*:2.9.0 is released. Version 2.9.0 contains these commits .
Important changes since 2.8.0
- A new
androidx.lifecycle:lifecycle-viewmodel-testingKMP artifact is available that provides aViewModelScenarioclass for testingViewModelsin isolation, with support foronClearedandSavedStateHandleas well as testing process death and recreation viarecreate(). - Add
getMutableStateFlowtoSavedStateHandleto return aMutableStateFlow. This new function is key-exclusive and cannot be used withgetLiveData. An exception will be thrown if you try to use both to access the same state. -
CreationExtrasnow includes map-like operator overloads to enable idiomatic manipulation of content in Kotlin. It allows the use ofin,+=, and+withCreationExtras.
KotlinX Serialization Support
With the support of KotlinX Serialization added in SavedState
1.3.0, we have introducedsaved, a lazy property delegate, to make it easy to store@Serializableclasses in aSavedStateHandleand have those classes automatically be restored across process death and recreation. Please note thesaveddelegate is lazy and will not call theinitlambda or save anything into theSavedStateHandleuntil it is accessed.@Serializable data class Person(val firstName: String, val lastName: String) class MyViewModel(handle: SavedStateHandle) : ViewModel() { var person by handle.saved { Person("John", "Doe") } fun onPersonChanged(person: Person) { this.person = person } }
Kotlin Multiplatform
- The
lifecycle-testingmodule is now KMP compatible including APIs likeTestLifecycleOwner. - The
lifecycle-viewmodel-savedstatemodule is now KMP compatible including APIs likeSavedStateHandle. - The
androidx.compose.ui.platform.LocalLifecycleOwneris now available in the common source set. -
NewInstanceFactoryis now available on JVM Desktop and Android targets.
আচরণগত পরিবর্তন
- The
Lifecycle.DESTROYEDstate is terminal, and any attempt to move aLifecyclefrom it to any other state will now result in anIllegalStateException. -
SavedStateHandleno longer includes anySavedStateProvider.saveState()where the returnedBundleis empty.
Version 2.9.0-rc01
২৩ এপ্রিল, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-rc01 is released. Version 2.9.0-rc01 contains these commits .
Lint API Compatibility Warning
- JetBrains changed
KaCallableMemberCallfrom a class to an interface , which breaks binary compatibility. This can cause crashes if your project's AGP version differs from the version used to compile lint checks. This update was made in aosp/3577172 but was missing from the release notes — we're clarifying it here. Recommended fix: Update to the latest stable AGP. If you can't fully update, useandroid.experimental.lint.versionto align lint checks with your AGP version — see Compose Runtime behavior changes for details.
Version 2.9.0-beta01
April 9, 2025
androidx.lifecycle:lifecycle-*:2.9.0-beta01 is released. Version 2.9.0-beta01 contains these commits .
API Changes
-
Lifecycle ViewModel Composenow uses the same Kotlin Multiplatform setup as Compose Runtime 1.7.1 and higher - the-desktopartifacts are now removed and-jvmStubsand-linuxx64Stubsartifacts have been added. None of these targets are meant to be used, they are placeholders to help Jetbrains Compose efforts. ( I5cb14 , b/406592090 )
Dependency Updates
- This library now targets Kotlin 2.0 language level and requires KGP 2.0.0 or newer. ( Idb6b5 )
-
Lifecycle ViewModel Composenow depends on Compose 1.7.8. ( I5cb14 , b/406592090 )
Version 2.9.0-alpha13
২৬ মার্চ, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha13 is released with no notable public changes. Version 2.9.0-alpha13 contains these commits .
Version 2.9.0-alpha12
১২ মার্চ, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha12 is released. Version 2.9.0-alpha12 contains these commits .
API Changes
- Add
@MainThreadannotation toViewModelProvider.getin all supported KMP platforms. ( I7e8dd , b/397736115 ) - Rename
SavedState*DelegatestoSavedState*Delegate. ( I8589b , b/399629301 )
Version 2.9.0-alpha11
২৬ ফেব্রুয়ারী, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha11 is released. Version 2.9.0-alpha11 contains these commits .
API Changes
- Add
SavedStateConfigparameter tosaved()delegates ( I39b3a )
Version 2.9.0-alpha10
১২ ফেব্রুয়ারী, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha10 is released. Version 2.9.0-alpha10 contains these commits .
API Changes
- Move
MutableStateSerializertosavedstate-composefromlifecycle-viewmodel-compose. ( I4f690 , b/378895074 )
External Contribution
- Adds a new Lint issue for calling
Lifecycle::currentStatein composition, instead suggesting usingcurrentStateAsalue().valueto ensure that changes in the Lifecycle state correctly cause recomposition. Thanks Steven Schoen! ( Iad484 )
Version 2.9.0-alpha09
২৯ জানুয়ারী, ২০২৫
androidx.lifecycle:lifecycle-*:2.9.0-alpha09 is released. Version 2.9.0-alpha09 contains these commits .
নতুন বৈশিষ্ট্য
- Add
MutableStateSerializerfor serializingandroidx.compose.runtime.MutableState. ( Idfc48 , b/378895074 )
API Changes
- Replace overloaded
SavedStateHandle.saved()delegate functions with default parameters ( Icd1c1 ) -
AbstractSavedStateViewModelFactoryis deprecated as it creates aSavedStateHandlefor everyViewModel, causing unnecessary overhead. UseViewModelProvider.FactorywithCreationExtras.createSavedStateHandleinstead for more efficientViewModelcreation. ( Ia920b , b/388590327 )
Version 2.9.0-alpha08
১১ ডিসেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha08 is released. Version 2.9.0-alpha08 contains these commits .
নতুন বৈশিষ্ট্য
- Add
ViewModelScenario.recreateto simulate a System Process Death recreating theViewModelunder test and all associated components. ( Id6a69 , b/381063087 ) -
LifecycleOwnerandViewModelStoreOwnerinstances retrieved via their respectivefindViewTreeAPIs can now be resolved through disjoint parents of a view, such as aViewOverlay. See the release notes of core or the documentation inViewTree.setViewTreeDisjointParentfor more information on disjoint view parents. ( I800f4 )
API Changes
- Make the namings and package organization more consistent with
SavedStateRegistryOwnerDelegate( I8c135 , b/376026744 )
Bug Fixes
- This library now uses JSpecify nullness annotations , which are type-use. Kotlin developers should use the following compiler argument to enforce correct usage:
-Xjspecify-annotations=strict(this is the default starting with version 2.1.0 of the Kotlin compiler). ( Ie4340 , b/326456246 ) - Document
ViewModel.onClearedclearing sequence. ( I586c7 , b/363984116 )
Version 2.9.0-alpha07
১৩ নভেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha07 is released. Version 2.9.0-alpha07 contains these commits .
Kotlin Multiplatform Compatibility
- Lifecycle
ViewModel SavedStateis now KMP compatible. This allows you to useSavedStateHandlein common code. ( Ib6394 , b/334076622 )
KotlinX Serialization Support
With the support of KotlinX Serialization added in SavedState
1.3.0-alpha05, we have introducedsaved, a lazy property delegate, to make it easy to store@Serializableclasses in aSavedStateHandleand have those classes automatically be restored across process death and recreation. Please note thesaveddelegate is lazy and will not call theinitlambda or save anything into theSavedStateHandleuntil it is accessed. ( I47a88 , b/376026744 )@Serializable data class Person(val firstName: String, val lastName: String) class MyViewModel(handle: SavedStateHandle) : ViewModel() { var person by handle.saved { Person("John", "Doe") } fun onPersonChanged(person: Person) { this.person = person } }
API Changes
- Add
getMutableStateFlowtoSavedStateHandleto return aMutableStateFlow. This new function is key-exclusive and cannot be used withgetLiveData. An exception will be thrown if you try to use both to access the same state. ( I04a4f , b/375408415 )
Version 2.9.0-alpha06
৩০ অক্টোবর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha06 is released. Version 2.9.0-alpha06 contains these commits .
আচরণগত পরিবর্তন
- The
Lifecycle.DESTROYEDstate is terminal, and any attempt to move aLifecyclefrom it to any other state will now result in anIllegalStateException. ( I116c4 , b/370577987 ) -
SavedStateHandleno longer includes anySavedStateProvider.saveState()where the returnedBundleis empty. ( I910b5 , b/370577987 )
Bug Fixes
-
Lifecycle.eventFlownow correctly complete whenLifecycleisDESTROYED( I293b2 , b/374043130 )
Version 2.9.0-alpha05
October 16, 2024
androidx.lifecycle:lifecycle-*:2.9.0-alpha05 is released with no notable changes. Version 2.9.0-alpha05 contains these commits .
Version 2.9.0-alpha04
October 2, 2024
androidx.lifecycle:lifecycle-*:2.9.0-alpha04 is released. Version 2.9.0-alpha04 contains these commits .
Kotlin Multiplatform
- The
lifecycle-viewmodel-savedstatemodule is now configured to be KMP compatible in preparation for APIs likeSavedStateHandlebeing made available in the common source set in a future release. ( I503ed , I48764 , b/334076622 )
Version 2.9.0-alpha03
১৮ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha03 is released. Version 2.9.0-alpha03 contains these commits .
Bug Fixes
- From Lifecycle
2.8.6: TheNullSafeMutableLiveDataLint error has improved support for smart casts, avoiding false positives. ( 85fed6 , b/181042665 )
Dependency Updates
- From Lifecycle
2.8.6: Lifecycle Runtime Compose now depends on Compose Runtime1.7.1 - Lifecycle Runtime now depends on ProfileInstaller
1.4.0
Version 2.9.0-alpha02
৪ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.9.0-alpha02 is released. Version 2.9.0-alpha02 contains these commits .
Bug Fixes
- From Lifecycle
2.8.5: Update theandroidx.lifecycle.ReportFragmentProGuard rules to allow obfuscation . ( ff898e1 )
External Contribution
- Move
androidx.compose.ui.platform.LocalLifecycleOwnerto common source set (KMP). Thanks Ivan Matkov from JetBrains for the contribution. ( 8cd5d03 ) - From Lifecycle
2.8.5: SavedStateHandle.saveable` extension delegate now supports nullable values. Thanks Roman Kalukiewicz for the contribution. ( 0d78ea6 )
Version 2.9.0-alpha01
August 7, 2024
androidx.lifecycle:lifecycle-*:2.9.0-alpha01 is released. Version 2.9.0-alpha01 contains these commits .
Kotlin Multiplatform
-
lifecycle-testingis now KMP compatible. ( Iea41e ) - Add support for
linuxArm64kotlin multiplatform target ( I139d3 , b/338268719 )
নতুন বৈশিষ্ট্য
- A new
androidx.lifecycle:lifecycle-viewmodel-testingKMP artifact is available that provides aViewModelScenarioclass for testing ViewModels in isolation, with support foronCleared(all platforms) andSavedStateHandle(Android only). ( 337f68d , c9b3409 , 9799a95c , b/264602919 ) - Creating a
ViewModelwithViewModelProvideris now thread safe;@MainThreadannotations have been removed. ( Ifd978 , b/237006831 )
API Changes
- Add the
CreationExtras.Key()factory function to simplify the creation of anonymousCreationExtras.Keyobjects. ( I970ee ) -
CreationExtrasnow includes map-like operator overloads to enable idiomatic manipulation of content in Kotlin. It allows the use ofin,+=, and+withCreationExtras. ( Ib4353 ) -
CreationExtrasnow implementsequals,hashCode, andtoStringmethods. ( Ib4353 ) -
NewInstanceFactoryis now available on JVM Desktop and Android targets. ( d3d0892 ) - Inline extension property to expose underlying Application safely in Kotlin language version 2.0 ( I39df2 )
Bug Fixes
- Removed manual outlining of access to new platform APIs since this happens automatically via API modeling when using R8 with AGP 7.3 or later (eg R8 version 3.3) and for all builds when using AGP 8.1 or later (eg D8 version 8.1). Clients who are not using AGP are advised to update to D8 version 8.1 or later. See this article for more details. ( If6b4c , b/345472586 )
Version 2.8
Version 2.8.7
৩০ অক্টোবর, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.7 is released. Version 2.8.7 contains these commits .
API Changes
-
androidx.compose.ui.platform.LocalLifecycleOwneris now available in the common source set (KMP). ( 6a3f5b3 ) -
lifecycle-runtime-compose:desktopartifacts were removed and-jvmStubsand-linuxx64Stubsartifacts were added. None of these targets are meant to be used, they are placeholders to help Jetbrains Compose efforts. ( 6a3f5b3 )
Version 2.8.6
১৮ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.6 is released. Version 2.8.6 contains these commits .
Bug Fixes
- The
NullSafeMutableLiveDataLint error has improved support for smart casts, avoiding false positives. ( 85fed6 , b/181042665 )
Dependency Updates
- Lifecycle Runtime Compose now depends on Compose Runtime
1.7.1
Version 2.8.5
৪ সেপ্টেম্বর, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.5 is released. Version 2.8.5 contains these commits .
Bug Fixes
- Update the
androidx.lifecycle.ReportFragmentProGuard rules to allow obfuscation . ( ff898e1 )
External Contribution
-
SavedStateHandle.saveableextension delegate now supports nullable values. Thanks Roman Kalukiewicz for the contribution. ( 0d78ea6 )
Version 2.8.4
July 24, 2024
androidx.lifecycle:lifecycle-*:2.8.4 is released. Version 2.8.4 contains these commits .
Bug Fixes
-
LiveData.asFlow()now correctly handles cases where the returned Flow is immediately completed after receiving a value already set on theLiveData(for example, when usingtake(1)). ( I9c566 ) -
Lifecycle*Effectcompletion is now idempotent (ie, if theonStopOrDisposewas called because of the Lifecycle being stopped, it won't be called a second time upon disposal unless the Lifecycle goes back up toSTARTEDagain). ( I5f607 , b/352364595 )
Version 2.8.3
July 1, 2024
androidx.lifecycle:lifecycle-*:2.8.3 is released. Version 2.8.3 contains these commits .
Bug Fixes
- Fixed an issue with Lifecycle 2.8's backward compatibility with Compose 1.6.0 and lower when using code shrinking. ( aosp/3133056 , b/346808608 )
Version 2.8.2
১২ জুন, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.2 is released. Version 2.8.2 contains these commits .
Bug Fixes
- Fixed
CompositionLocal LocalLifecycleOwner not presenterrors when using Lifecycle 2.8.X with Compose 1.6.X or earlier - you can now use Lifecycle 2.8.2 with any version of Compose without any workarounds required. ( aosp/3105647 , b/336842920 ) -
ViewModelProviderwill no longer crash when mixing previous versions ofcompileOnlyLifecycle dependencies with versions 2.8+, fixing issues with libraries such as LeakCanary. ( I80383 , b/341792251 )
Version 2.8.1
২৯ মে, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.1 is released. Version 2.8.1 contains these commits .
Bug Fixes
-
lifecycle-viewmodel-composenow only has a common dependency oncompose-runtime, removing its common dependency oncompose-ui. The Android artifact retains itscompose-uifor compatibility. ( aosp/3079334 , b/339562627 ) -
ViewModel'ssaveableintegration using property delegates now uses the class name as part of the auto-generated key, avoiding conflicts if multiple classes use the sameSavedStateHandle. ( aosp/3063463 )
Version 2.8.0
১৪ মে, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0 is released. Version 2.8.0 contains these commits .
Important changes since 2.7.0
-
LocalLifecycleOwnerhas been moved from Compose UI tolifecycle-runtime-composeso that its Compose-based helper APIs can be used outside of Compose UI. - The
lifecycle-runtime-composeartifact now contains thedropUnlessResumedanddropUnlessStartedAPIs which allow you to drop click or other events that occur even after theLifecycleOwnerhas dropped below the givenLifecycle.State. For example, this can be used with Navigation Compose to avoid handling click events after a transition to another screen has already begun:onClick: () -> Unit = dropUnlessResumed { navController.navigate(NEW_SCREEN) } ViewModel.viewModelScopeis now an overridable constructor parameter, allowing you to inject your own dispatcher andSupervisorJob()or to override the default by using thebackgroundScopeavailable withinrunTest. ( I2817c , b/264598574 )class MyViewModel( // Make Dispatchers.Main the default, rather than Dispatchers.Main.immediate viewModelScope: CoroutineScope = Dispatchers.Main + SupervisorJob() ) : ViewModel(viewModelScope) { // Use viewModelScope as before, without any code changes } // Allows overriding the viewModelScope in a test fun Test() = runTest { val viewModel = MyViewModel(backgroundScope) }ViewModelhas been rewritten in Kotlin and now usesAutoClosableinstead ofCloseable. It now supports addingAutoCloseableobjects with akeythat allows retrieving them viagetCloseable().Calling
LifecycleStartEffectandLifecycleResumeEffectwithout a key is now an error, following the same convention as theDisposableEffectAPI that these APIs mirror.Deprecated
LiveDataReactiveStreams.toPublisher(lifecycleOwner, liveData)in favor ofLiveData.toPublisher(lifecycleOwner).The
lifecycle-livedata-core-ktxkotlin extensions have now been moved to thelifecycle-livedata-coremodule.The
NullSafeMutableLiveDatahas been refactored to avoid many false positives.
Lifecycle Kotlin Multiplatform Compatibility
The core Lifecycle APIs in Lifecycle , LifecycleOwner , LifecycleObserver , Lifecycle.State , Lifecycle.Event , and LifecycleRegistry are now shipped in artifacts compatible with Kotlin Multiplatform.
Artifacts impacted:
-
lifecycle-commonmoves most APIs tocommonand supports jvm and iOS in addition to Android. -
lifecycle-runtimemoves most APIs tocommonand supports jvm and iOS in addition to Android. -
lifecycle-runtime-ktxis now empty, with all APIs being moved intolifecycle-runtime. -
lifecycle-runtime-composemoves all APIs tocommonand ships an Android artifact, matching the multiplatform support ofandroidx.compose.
ViewModel Kotlin Multiplatform Compatibility
The lifecycle-viewmodel artifact and APIs like ViewModel , ViewModelStore , ViewModelStoreOwner , and ViewModelProvider are now shipped in artifacts compatible with Kotlin Multiplatform.
To accommodate this change, methods such as those on ViewModelProvider that took a java.lang.Class<T> now have an equivalent method that takes a kotlin.reflect.KClass<T> .
Binary compatibility on Android has been maintained, but there are a few notable changes when comparing the Android API surface to the common API surface:
- Constructing a
ViewModelProviderinstance is now done through theViewModelProvider.create()methods rather than directly calling its constructor. -
ViewModelProvider.NewInstanceFactoryandViewModelProvider.AndroidViewModelFactoryare only available on Android.- Custom Factories are recommended to extend from
ViewModelProvider.Factoryand use thecreatemethod that takes aCreationExtrasor use theviewModelFactoryKotlin DSL.
- Custom Factories are recommended to extend from
- Using
ViewModelProviderwithout a custom factory on non-JVM platforms will result in anUnsupportedOperationException. On JVM platforms, compatibility is preserved by using the no-args ViewModel constructor if a custom factory is not provided. -
viewModelScopewill fallback to anEmptyCoroutineContextin platforms whereDispatchers.Mainis not available (eg, Linux).
Artifacts impacted:
-
lifecycle-viewmodelmoves most APIs tocommonand supports jvm and iOS in addition to Android. -
lifecycle-viewmodel-ktxis now empty, with all APIs being moved intolifecycle-viewmodel. -
lifecycle-viewmodel-composemoves all APIs tocommonand ships an Android artifact, matching the multiplatform support ofandroidx.compose.
আচরণগত পরিবর্তন
-
InitializerViewModelFactory(includingviewModelFactorybuilder function) will now throw anIllegalArgumentExceptionif ainitializerwith the sameclazz: KClass<VM : ViewModel>has already been added. ( Ic3a36 )
জ্ঞাত সমস্যা
-
lifecycle-*:2.8.0requires a minimum Compose version of 1.7.0-alpha05 ( b/336842920 ).
Version 2.8.0-rc01
১ মে, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-rc01 is released. Version 2.8.0-rc01 contains these commits .
Bug Fixes
- Fixed an issue where the Baseline Profile for
lifecycle-commonclasses was not properly packaged. These are now packaged in thelifecycle-runtimeAAR. ( aosp/3038274 , b/322382422 ) - Fixed an unintentional ordering change in how
AutoCloseableinstances attached to a ViewModel are cleared - the previous order ofaddCloseable(String, AutoCloseable), thenaddClosable(AutoCloseable), thenonCleared()has been restored. ( aosp/3041632 ) - Improve the default creation behavior for
viewModelScopefor native and JVM Desktop environments. ( aosp/3039221 )
External Contribution
- Thanks Victor Kropp for improving the checking for the main thread on JVM Desktop. ( aosp/3037116 )
Version 2.8.0-beta01
১৭ এপ্রিল, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-beta01 is released. Version 2.8.0-beta01 contains these commits .
নতুন বৈশিষ্ট্য
- The
lifecycle-runtime-composeartifact is now compatible with Kotlin Multiplatform, moving its code tocommonand ships an Android artifact, matching the multiplatform support forandroidx.compose. ( If7a71 , I4f4a0 , b/331769623 )
Version 2.8.0-alpha04
April 3, 2024
androidx.lifecycle:lifecycle-*:2.8.0-alpha04 is released. Version 2.8.0-alpha04 contains these commits .
নতুন বৈশিষ্ট্য
- The
lifecycle-viewmodel-composeartifact is now compatible with Kotlin Multiplatform, moving its code tocommonand ships an Android artifact, matching the multiplatform support ofandroidx.compose. The accommodate this change, the ComposableviewModelmethod now accepts aKClassin addition to ajava.lang.Class. ( b/330323282 )
Bug Fixes
- The
NullSafeMutableLiveDatahas been refactored to avoid many false positives. ( I2d8c1 , Iafb18 , I03463 , I7ecef )
Dependency update
- The
lifecycle-viewmodel-composeartifact now depends on Compose 1.6.0. - Lifecycle now depends on Profile Installer 1.3.1 .
Version 2.8.0-alpha03
২০ মার্চ, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-alpha03 is released. Version 2.8.0-alpha03 contains these commits .
নতুন বৈশিষ্ট্য
ViewModel.viewModelScopeis now an overridable constructor parameter, allowing you to inject your own dispatcher andSupervisorJob()or to override the default by using thebackgroundScopeavailable withinrunTest. ( I2817c , b/264598574 )class MyViewModel( // Make Dispatchers.Main the default, rather than Dispatchers.Main.immediate viewModelScope: CoroutineScope = Dispatchers.Main + SupervisorJob() ) : ViewModel(viewModelScope) { // Use viewModelScope as before, without any code changes } // Allows overriding the viewModelScope in a test fun Test() = runTest { val viewModel = MyViewModel(backgroundScope) }
Kotlin Multiplatform Compatibility
The lifecycle-viewmodel artifact and APIs like ViewModel , ViewModelStore , ViewModelStoreOwner , and ViewModelProvider are now shipped in artifacts compatible with Kotlin Multiplatform. ( b/214568825 )
To accommodate this change, methods such as those on ViewModelProvider that took a java.lang.Class<T> now have an equivalent method that takes a kotlin.reflect.KClass<T> .
Binary compatibility on Android has been maintained, but there are a few notable changes when comparing the Android API surface to the common API surface:
- Constructing a
ViewModelProviderinstance is now done through theViewModelProvider.create()methods rather than directly calling its constructor. -
ViewModelProvider.NewInstanceFactoryandViewModelProvider.AndroidViewModelFactoryare only available on Android.- Custom Factories are recommended to extend from
ViewModelProvider.Factoryand use thecreatemethod that takes aCreationExtrasor use theviewModelFactoryKotlin DSL.
- Custom Factories are recommended to extend from
- Using
ViewModelProviderwithout a custom factory on non-JVM platforms will result in anUnsupportedOperationException. On JVM platforms, compatibility is preserved by using the no-args ViewModel constructor if a custom factory is not provided. -
viewModelScopewill fallback to anEmptyCoroutineContextin platforms whereDispatchers.Mainis not available (eg, Linux).
আচরণগত পরিবর্তন
-
InitializerViewModelFactory(includingviewModelFactorybuilder function) will now throw anIllegalArgumentExceptionif ainitializerwith the sameclazz: KClass<VM : ViewModel>has already been added. ( Ic3a36 )
Bug Fixes
-
ViewModel.getCloseablenow handles duplicated keys: if thekeyalready has anAutoCloseableresource associated with it, the old resource will be replaced and closed immediately. ( Ibeb67 ) - Accessing the
viewModelScopeof aViewModelis now thread safe. ( If4766 , b/322407038 )
External Contribution
-
LocalLifecycleOwnermoved from Compose UI to lifecycle-runtime-compose so that its Compose-based helper APIs can be used outside of Compose UI. Thanks Jake Wharton for the contribution. ( I6c41b , b/328263448 )
Version 2.8.0-alpha02
২১ ফেব্রুয়ারী, ২০২৪
androidx.lifecycle:lifecycle-*:2.8.0-alpha02 is released. Version 2.8.0-alpha02 contains these commits.
নতুন বৈশিষ্ট্য
- The
dropUnlessResumedanddropUnlessStartedAPIs have been added which allow you to drop click or other events that occur even after theLifecycleOwnerhas dropped below the givenLifecycle.State. For example, this can be used with Navigation Compose to avoid handling click events after a transition to another screen has already begun:onClick: () -> Unit = dropUnlessResumed { navController.navigate(NEW_SCREEN) }( Icba83 , b/317230685 )
Kotlin Conversions
-
ViewModelis now written in Kotlin ( I16f26 , b/214568825 ) - The
lifecycle-viewmodel-ktxkotlin extensions have now been moved to the base lifecycle module. ( Id787b , b/274800183 ) - The
lifecycle-runtime-ktxkotlin extensions have now been moved to the base lifecycle module. ( Ic3686 , b/274800183 ) - The
lifecycle-livedata-core-ktxkotlin extensions have now been moved to the base lifecycle module. ( I54a3d , b/274800183 )
Kotlin Multiplatform Compatibility
- The core Lifecycle APIs in
Lifecycle,LifecycleOwner,LifecycleObserver,Lifecycle.State,Lifecycle.Event, andLifecycleRegistryare now shipped in artifacts compatible with Kotlin Multiplatform. ( b/317249252 )
API Changes
- Calling
LifecycleStartEffectandLifecycleResumeEffectwithout a key is now an error, following the same convention as theDisposableEffectAPI that these APIs mirror. ( Ib0e0c , b/323518079 ) -
ViewModelnow usesAutoCloseableinstead ofCloseable. That is a backward compatible change. ( I27f8e , b/214568825 ) - Deprecated
LiveDataReactiveStreams.toPublisher(lifecycleOwner, liveData)in favor ofLiveData.toPublisher(lifecycleOwner). ( Iabe29 , b/262623005 )
External Contribution
- Thanks Ivan Matkov from Jetbrains for helping move Lifecycle to Kotlin Multiplatform. ( aosp/2926690 , I0c5ac , If445d )
Version 2.8.0-alpha01
January 24, 2024
androidx.lifecycle:lifecycle-*:2.8.0-alpha01 is released. Version 2.8.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
-
ViewModelnow supports addingCloseableobjects with akeythat allows retrieving them viagetCloseable(). ( I3cf63 )
Version 2.7
সংস্করণ 2.7.0
January 10, 2024
androidx.lifecycle:lifecycle-*:2.7.0 is released. Version 2.7.0 contains these commits.
Important changes since 2.6.0
-
TestLifecycleOwnernow includes a suspending functionsetCurrentState()which ensures that the state change and allLifecycleObservercallbacks are completed before returning. Notably, unlike setting thecurrentStateproperty directly, this does not userunBlocking, making it safe to use within a coroutine such as one provided byrunTest. - The
LiveDataextensions ofmapandswitchMapnow mirror the behavior ofdistinctUntilChanged- if theLiveDatahas avalueset, themap/switchMapfunction will be immediately called to populate thevalueof the returnedLiveData. This ensures that the initial value will be set as part of the first composition (when used withobserveAsState()), but does not change the observation behavior - updates values from the sourceLiveDatawill still only apply once you start observing theLiveData. - This release fixes an issue where
SavedStateHandlewould not properly restore customParcelableclasses after process death and recreation. Due to type information that is lost by the Android framework, arrays of custom Parcelables require additional work (manually creating a typed array of the right type) and the documentation onget,getLiveData, andgetStateFlownow specifically calls this limitation out. - The proguard keep rules associated with
LifecycleObserverhave been removed. This means that proguarded code that wishes to use APIs via reflection (such as using the long since deprecated@OnLifecycleEventannotation) will need to provide their own keep rules for their specific use case.
Lifecycle Event Observability
- As an alternative to using a
LifecycleEventObserver, you can now observe aFlowofLifecycle.Eventvia theLifecycle.asFlow()extension method. - Jetpack Compose users can now use
LifecycleEventEffectto run Compose side effects based onLifecycle.Event.
@Composable
fun HomeScreen(viewModel: HomeViewModel = viewModel()) {
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
viewModel.refreshData()
}
// …
}
- Jetpack Compose users can use
LifecycleStartEffectandLifecycleResumeEffectto handle pairs of events - started to stopped and resumed to paused, respectively. This API mirrors the one found inDisposableEffectand is suitable for cases where the change being made when the state is going up needs to be reversed when going back down.
fun HomeScreen(viewModel: HomeViewModel = viewModel()) {
LifecycleStartEffect(viewModel) {
val timeTracking = viewModel.startTrackingTimeOnScreen()
onStopOrDispose {
timeTracking.stopTrackingTimeOnScreen()
}
}
// …
}
See Run code on lifecycle events for more information.
Lifecycle State Observability
- The current
Lifecycle.Statecan now be observed via theLifecycle.currentStateFlowproperty, which returns aStateFlowwhere thevalueis the currentLifecycle.State. - Jetpack Compose users can use the
Lifecycle.currentStateAsState()extension to directly exposeLifecycle.Stateas ComposeState. This is equivalent (and a shorter alternative) tolifecycle.currentStateFlow.collectAsState().
See Collect lifecycle state with flows for more information.
Version 2.7.0-rc02
১৩ ডিসেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-rc02 is released. Version 2.7.0-rc02 contains these commits.
Bug Fixes
- Fixed an issue where
SavedStateHandlewould not properly restore customParcelableclasses after process death and recreation. Due to type information that is lost by the Android framework, arrays of custom Parcelables require additional work (manually creating a typed array of the right type) and the documentation onget,getLiveData, andgetStateFlownow specifically calls this limitation out. ( I0b55a )
Version 2.7.0-rc01
১৫ নভেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-rc01 is released. Version 2.7.0-rc01 contains these commits.
Bug Fixes
-
LifecycleStartEffectandLifecycleResumeEffectnow correctly dispose and recreate the effect block if theLifecycleOwneris changed. ( Ia25c6 )
Version 2.7.0-beta01
১ নভেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-beta01 is released with no changes. Version 2.7.0-beta01 contains these commits.
- A beta version bump, no major changes to this release version.
Version 2.7.0-alpha03
October 18, 2023
androidx.lifecycle:lifecycle-*:2.7.0-alpha03 is released. Version 2.7.0-alpha03 contains these commits.
নতুন বৈশিষ্ট্য
-
lifecycle-runtime-testingnow contains a new Lint check to avoid setting theLifecycle.Stateof theTestLifecycleOwnerby using thecurrentStatefield when inside of a coroutine. The Lint check now suggests the suspendingsetCurrentStatewhich allows setting theLifecycle.Statewithout blocking. ( Icf728 , b/297880630 )
Bug Fixes
- Fixed an issue with
LiveData.switchMapwhere returning the sameLiveDatainstance both on the initial call and a subsequent call would prevent theLiveDatainstance from being added as a source. ( Ibedcba7 )
Version 2.7.0-alpha02
৬ সেপ্টেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.7.0-alpha02 is released. Version 2.7.0-alpha02 contains these commits.
নতুন বৈশিষ্ট্য
-
TestLifecycleOwnernow includes the suspending functionsetCurrentState()to give users the option of usingTestLifecycleOwnerfrom within a coroutine such as one provided byrunTest. ( I329de , b/259344129 )
API Changes
- All files from the
lifecycle-livedata-ktxmodules have been moved into the mainlifecycle-livedatamodule. ( I10c6f , b/274800183 )
আচরণগত পরিবর্তন
- The
LiveData.map()andLiveData.switchMap()extensions now sets thevalueof the returnedLiveDataif the previousLiveDatahas had a value set on it, ensuring that using the resulting LiveData in Jetpack Compose has the right state on the initial composition. ( I91d2b , b/269479952 ) -
ViewModel'saddCloseable()now immediately closes theCloseableif theViewModelhas already received a call toonCleared(). ( I4712e , b/280294730 )
Bug Fixes
- From Lifecycle
2.6.2: Fixed an issue whereSavedStateHandlewould not correctly be restored after process death if the state was restored,save()was called without actually saving the state in the parentSavedStateRegistry, and then the state was restored again. This fixes the interaction betweenrememberSaveableand Navigation Compose'sNavHost. ( aosp/2729289 )
Version 2.7.0-alpha01
July 26, 2023
androidx.lifecycle:lifecycle-*:2.7.0-alpha01 is released. Version 2.7.0-alpha01 contains these commits.
API Changes
-
Lifecycle.Stateis now Compose-observable viaLifecycle.currentStateFlow, which returns aStateFlowwhere thevalueis the currentLifecycle.State. ( Ib212d , b/209684871 ) -
Lifecycle.Events can now able to be observed as aFlowwithLifecycle.asFlow().( If2c0f , b/176311030 ) -
LifecycleResumeEffectAPI has been added to run ComposeSideEffects based on bothLifecycle.Event.ON_RESUMEandLifecycle.Event.ON_PAUSEevent callbacks. ( I60386 , b/235529345 ) -
LifecycleStartEffectAPI has been added to run ComposeSideEffects based onLifecycle.Event.ON_STARTandLifecycle.Event.ON_STOPevent callbacks. ( I5a8d1 , b/235529345 ) -
LifecycleEventEffectAPI has been added to run ComposeSideEffects based onLifecycle.Event. ( Ic9794 , b/235529345 ) -
Lifecycle.collectAsState()extension has been added to directly exposeLifecycle.Stateas ComposeState. This is equivalent (and a shorter alternative) tolifecycle.currentStateFlow.collectAsState(). ( I11015 , b/235529345 )
Bug Fixes
- The
LiveData.distinctUntilChanged()extension now sets thevalueof the returnedLiveDataif the previousLiveDatahas had a value set on it. This does not change the observation behavior - updated values from the sourceLiveDatawill still only apply once you start observing theLiveDatareturned fromdistinctUntilChanged(). ( Ib482f ) - The proguard keep rules associated with
LifecycleObserverhave been removed. This means that proguarded code that wishes to use APIs via reflection will need to provide their own keep rules for their specific use case. ( Ia12fd )
Version 2.6
Version 2.6.2
৬ সেপ্টেম্বর, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.2 is released. Version 2.6.2 contains these commits.
Bug Fixes
- Fixed an issue where
SavedStateHandlewould not correctly be restored after process death if the state was restored,save()was called without actually saving the state in the parentSavedStateRegistry, and then the state was restored again. This fixes the interaction betweenrememberSaveableand Navigation Compose'sNavHost. ( aosp/2729289 )
Version 2.6.1
২২ মার্চ, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.1 is released. Version 2.6.1 contains these commits.
Dependency Updates
-
lifecycle-viewmodel-savedstatenow depends on SavedState1.2.1. ( cd7251 ) - Lifecycle now depends on ProfileInstaller
1.3.0. ( f9d30b )
সংস্করণ 2.6.0
৮ মার্চ, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0 is released. Version 2.6.0 contains these commits.
Important changes since 2.5.0
-
LiveDatanow includes a newisInitializedproperty that indicates whether an explicit value has ever been set on theLiveData, allowing you to distinguish betweenliveData.valuereturningnullbecause no value has ever been set or an explicitnullvalue. -
MediatorLiveDatanow includes a constructor to set an initial value. - Added a new extension on
StateFlowandFlowofcollectAsStateWithLifecycle()that collect from flows and represents its latest value as Compose State in a lifecycle-aware manner. -
Lifecycle.launchWhenXmethods andLifecycle.whenXmethods have been deprecated as the use of a pausing dispatcher can lead to wasted resources in some cases. It is recommended to useLifecycle.repeatOnLifecycle. For more information about one-time suspending work, please see this explanation on why this is inherently unsafe. - Kotlin Conversion - A large number of Lifecycle classes have been converted to Kotlin. All converted classes still retain their binary compatibility with previous versions. The following classes have source incompatible changes for classes written in Kotlin:
ViewTreeLifecycleOwner,LiveDataReactiveStreams,HasDefaultViewModelProviderFactory,ViewTreeViewModelStoreOwner,Transformations,ViewModelStoreOwner,LifecycleOwner
The table below provides the source conversions for the new version of lifecycle.
| Lifecycle 2.5 | Lifecycle 2.5 (KTX) | Lifecycle 2.6 |
|---|---|---|
Transformations.switchMap(liveData) {...} | liveData.switchMap {...} | liveData.switchMap {...} |
Transformations.map(liveData) {...} | liveData.map {...} | liveData.map {...} |
Transformations.distinctUntilChanged(liveData) {...} | liveData.distinctUntilChanged{...} | liveData.distinctUntilChanged{...} |
LiveDataReactiveStreams.fromPublisher(publisher) | publisher.toLiveData() | publisher.toLiveData() |
LiveDataReactiveStreams.toPublisher(lifecycleOwner, liveData) | liveData.toPublisher(lifecycleOwner) | liveData.toPublisher(lifecycleOwner) |
override fun getDefaultViewModelProviderFactory(): ViewModelProvider.Factory = factory | override fun getDefaultViewModelProviderFactory(): ViewModelProvider.Factory = factory | override val defaultViewModelProviderFactory = factory |
override fun getDefaultViewModelCreationExtras(): CreationExtras = extras | override fun getDefaultViewModelCreationExtras(): CreationExtras = extras | override val defaultViewModelProviderCreationExtras = extras |
ViewTreeLifecycleOwner.set(view, owner) | ViewTreeLifecycleOwner.set(view, owner) | view.setViewTreeLifecycleOwner(owner) |
ViewTreeLifecycleOwner.get(view) | view.findViewTreeLifecycleOwner() | view.findViewTreeLifecycleOwner() |
override fun getViewModelStore(): ViewModelStore = store | override fun getViewModelStore(): ViewModelStore = store | override val viewModelStore: ViewModelStore = store |
override fun getLifecycle(): Lifecycle = registry | override fun getLifecycle(): Lifecycle = registry | override val lifecycle: Lifecycle get() = registry |
- The nullability of the
onChangedmethod of aObservercreated in Kotlin now matches the nullability of the generic type. If you wantObserver.onChanged()to accept a nullable type, you must instantiate theObserverwith a nullable type. - These classes were also converted to Kotlin, but remain source compatible:
DefaultLifecycleObserver,LifecycleEventObserver,Lifecycle,LifecycleRegistry,LifecycleObserver,ViewModelStore,AndroidViewModel,AbstractSavedStateViewModelFactory,LifecycleService,ServiceLifecycleDispatcher, andProcessLifecycleOwner
Version 2.6.0-rc01
February 22, 2023
androidx.lifecycle:lifecycle-*:2.6.0-rc01 is released. Version 2.6.0-rc01 contains these commits.
Bug Fixes
- The
LiveData.distinctUntilChanged()extension now sets thevalueof the returnedLiveDataif the previousLiveDatahas had a value set on it. This does not change the observation behavior - updated values from the sourceLiveDatawill still only apply once you start observing theLiveDatareturned fromdistinctUntilChanged(). ( Ib482f )
Version 2.6.0-beta01
৮ ফেব্রুয়ারী, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0-beta01 is released. Version 2.6.0-beta01 contains these commits.
Kotlin Conversions
-
LifecycleOwneris now written in Kotlin. This is a source incompatible change for classes written in Kotlin - they must now override thelifecycleproperty rather than implementing the previousgetLifecycle()function. ( I75b4b , b/240298691 ) -
ViewModelStoreOwneris now in Kotlin. This is a source incompatible change for classes written in Kotlin - they must now override theviewModelStoreproperty rather than implementing the previousgetViewModelStore()function. ( I86409 , b/240298691 ) - The Kotlin extension on
LifecycleOwnerthat provides thelifecycleScopefield has been moved to thelifecycle-commonartifact fromlifecycle-runtime-ktx. ( I41d78 , b/240298691 ) - The Kotlin extension on
Lifecyclethat provides thecoroutineScopefield has been moved to thelifecycle-commonartifact fromlifecycle-runtime-ktx. ( Iabb91 , b/240298691 )
Version 2.6.0-alpha05
২৫ জানুয়ারী, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0-alpha05 is released. Version 2.6.0-alpha05 contains these commits.
Kotlin Conversions
-
Transformationsis now written in Kotlin. This is a source incompatible change for those classes written in Kotlin that were directly using syntax such asTransformations.map- Kotlin code must now use the Kotlin extension method syntax that was previously only available when usinglifecycle-livedata-ktx. When using the Java programming language, the versions of these methods that take anandroidx.arch.core.util.Functionmethod are deprecated and replaced with the versions that take a KotlinFunction1. This change maintains binary compatibility. ( I8e14f ) -
ViewTreeViewModelStoreOwneris now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now directly import and use the Kotlin extension methods onViewofandroidx.lifecycle.setViewTreeViewModelStoreOwnerandandroidx.lifecycle.findViewTreeViewModelStoreOwnerto set and find a previously set owner. This is binary compatible and remains source compatible for implementations written in the Java programming language. ( Ia06d8 , Ib22d8 , b/240298691 ) - The
HasDefaultViewModelProviderFactoryinterface is now written in Kotlin. This is a source incompatible change for classes written in Kotlin - they must now override thedefaultViewModelProviderFactoryanddefaultViewModelCreationExtrasproperties rather than implementing the previous corresponding functions. ( Iaed9c , b/240298691 ) -
Observeris now written in Kotlin. ItsonChanged()method now uses the namevaluefor its parameter. ( Iffef2 , I4995e , b/240298691 ) -
AndroidViewModel,AbstractSavedStateViewModelFactory,LifecycleService,ServiceLifecycleDispatcher, andProcessLifecycleOwnerare now written in Kotlin ( I2e771 , Ibae40 , I160d7 , I08884 , I1cda7 , b/240298691 )
Version 2.6.0-alpha04
১১ জানুয়ারী, ২০২৩
androidx.lifecycle:lifecycle-*:2.6.0-alpha04 is released. Version 2.6.0-alpha04 contains these commits.
নতুন বৈশিষ্ট্য
-
LiveDatanow includes a newisInitializedproperty that indicates whether an explicit value has ever been set on theLiveData, allowing you to distinguish betweenliveData.valuereturningnullbecause no value has ever been set or an explicitnullvalue. ( Ibd018 )
API Changes
- The
collectAsStateWithLifecycle()APIs oflifecycle-runtime-composeare no longer in experimental status. ( I09d42 , b/258835424 ) -
Lifecycle.launchWhenXmethods andLifecycle.whenXmethods have been deprecated as the use of a pausing dispatcher can lead to wasted resources in some cases. It is recommended to useLifecycle.repeatOnLifecycle. ( Iafc54 , b/248302832 )
Kotlin Conversions
-
ViewTreeLifecycleOwneris now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now directly import and use the Kotlin extension methods onViewofandroidx.lifecycle.setViewTreeLifecycleOwnerandandroidx.lifecycle.findViewTreeLifecycleOwnerto set and find a previously set owner. This replaces the previous Kotlin extension inlifecycle-runtime-ktx. This is binary compatible and remains source compatible for implementations written in the Java programming language. ( I8a77a , I5234e , b/240298691 ) -
LiveDataReactiveStreamsis now written in Kotlin. The Kotlin extensions previously inlifecycle-reactivestreams-ktxhave been moved into thelifecycle-reactivestreamsmodule and have become the primary surface for code written in Kotlin. This is a source incompatible change for code written in Kotlin if you were not already using the Kotlin extension method APIs. ( I2b1b9 , I95d22 , b/240298691 ) -
DefaultLifecycleObserver,LifecycleEventObserver,Lifecycle,LifecycleRegistry,LifecycleObserver, andViewModelStoreare now written in Kotlin ( Iadffd , ( I60034 , I8c52c , I9593d , I01fe1 , I59a23 , b/240298691 )
Bug Fixes
-
SavedStateHandleno longer crashes with aClassCastExceptionwhen callingget()with the incorrect class type. ( I6ae7c )
Version 2.6.0-alpha03
October 24, 2022
androidx.lifecycle:lifecycle-*:2.6.0-alpha03 is released. Version 2.6.0-alpha03 contains these commits.
Bug Fixes
- Fixed an issue with constraints between different Lifecycle modules not working as intended. ( I18d0d , b/249686765 )
- Errors thrown by
LifecycleRegistry.moveToState()now include a more helpful error messaging that informs developers of the component causing the error. ( Idf4b2 , b/244910446 )
Version 2.6.0-alpha02
৭ সেপ্টেম্বর, ২০২২
androidx.lifecycle:lifecycle-*:2.6.0-alpha02 is released. Version 2.6.0-alpha02 contains these commits.
API Changes
-
MediatorLiveDatanow includes a constructor to set an initial value. ( Ib6cc5 , b/151244085 )
Bug Fixes
-
Lifecycleartifacts now include constraints that ensure that all inter-dependent Lifecycle artifacts use the same version, automatically upgrading other dependencies when one is upgraded. b/242871265 -
FlowLiveData.asFlow()now creates acallbackFlowrather than using its ownChannelimplementation to ensure thread-safety and context preservation. ( I4a8b2 , b/200596935 ) -
FlowLiveData'sasLiveDatafunction will now preserve the initial value of aStateFlowwhen creating the newLiveDataobject. ( I3f530 , b/157380488 ) - From Lifecycle
2.5.1: Custom implementations ofAndroidViewModelFactorynow correctly calls thecreate(modelClass)function when using the stateful constructor withLifecycle2.4+ ( I5b315 , b/238011621 )
Version 2.6.0-alpha01
২৯ জুন, ২০২২
androidx.lifecycle:lifecycle-*:2.6.0-alpha01 is released. Version 2.6.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
- Added a new extension on
StateFlowandFlowofcollectAsStateWithLifecyclethat collect from flows and represents its latest value as Compose State in a lifecycle-aware manner. The flow is collected and the new emission is set to the State's value when the lifecycle is at least in a certainLifecycle.State. When the lifecycle falls below thatLifecycle.State, the flow collection stops and the State's value is not updated. ( I1856e , b/230557927 )
Version 2.5
Version 2.5.1
২৭ জুলাই, ২০২২
androidx.lifecycle:lifecycle-*:2.5.1 is released. Version 2.5.1 contains these commits.
Bug Fixes
- Custom implementations of
AndroidViewModelFactorynow correctly call thecreate(modelClass)function when using the statefulAndroidViewModelFactoryconstructor withLifecycle2.4+. ( I5b315 , b/238011621 )
সংস্করণ 2.5.0
২৯ জুন, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0 is released. Version 2.5.0 contains these commits.
Important changes since 2.4.0
SavedStateHandlenow offers agetStateFlow()API that returns a KotlinStateFlowfor monitoring value changes as an alternative to usingLiveData.ViewModel CreationExtras - when writing a custom
ViewModelProvider.Factory, it is no longer required to extendAndroidViewModelFactoryorAbstractSavedStateViewModelFactoryto gain access to anApplicationorSavedStateHandle, respectively. Instead, these fields are provided to everyViewModelProvider.Factorysubclass asCreationExtrasvia the new overload ofcreate:create(Class<T>, CreationExtras). These extras are provided automatically by your Activity or Fragment when using Activity1.5.0and Fragment1.5.0, respectively.class CustomFactory : ViewModelProvider.Factory { override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T { return when (modelClass) { HomeViewModel::class -> { // Get the Application object from extras val application = checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY]) // Pass it directly to HomeViewModel HomeViewModel(application) } DetailViewModel::class -> { // Create a SavedStateHandle for this ViewModel from extras val savedStateHandle = extras.createSavedStateHandle() DetailViewModel(savedStateHandle) } else -> throw IllegalArgumentException("Unknown class $modelClass") } as T } }lifecycle-viewmodelnow provides aviewModelFactoryKotlin DSL that allows you define yourViewModelProvider.Factoryin terms of one or more lambda initializers, one for each particularViewModelclass your custom factory supports, usingCreationExtrasas the primary data source.val customFactory = viewModelFactory { // The return type of the lambda automatically sets what class this lambda handles initializer { // Get the Application object from extras provided to the lambda val application = checkNotNull(get(ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY)) HomeViewModel(application) } initializer { val savedStateHandle = createSavedStateHandle() DetailViewModel(savedStateHandle) } }lifecycle-viewmodel-composenow offers aviewModel()API that takes a lambda factory for creating aViewModelinstance without requiring the creation of a customViewModelProvider.Factory.// Within a @Composable, you can now skip writing a custom Factory // and instead write a lambda to do the initialization of your ViewModel val detailViewModel = viewModel { // This lambda is only called the first time the ViewModel is created // and all CreationExtras are available inside the lambda val savedStateHandle = createSavedStateHandle() DetailViewModel(savedStateHandle) }SavedStateHandle Compose Saver Integration - the
lifecycle-viewmodel-composeartifact now contains new experimental APIs inSavedStateHandle.saveablethat allowrememberSaveablelike behavior backed by theSavedStateHandleof a `ViewModel.class ListScreenViewModel(handle: SavedStateHandle): ViewModel() { // This value survives both configuration changes and process death and recreation val editMode by handle.saveable { mutableStateOf(false) } }Added an
addCloseable()API and a new constructor overload that allow you to add one or moreCloseableobjects to theViewModelthat will be closed when theViewModelis cleared without requiring any manual work inonCleared().For instance, to create a coroutine scope that you can inject into a ViewModel, but control via testing, you can create a
CoroutineScopethat implementsCloseable:class CloseableCoroutineScope( context: CoroutineContext = SupervisorJob() + Dispatchers.Main.immediate ) : Closeable, CoroutineScope { override val coroutineContext: CoroutineContext = context override fun close() { coroutineContext.cancel() } }Which can then be used in your
ViewModelconstructor while maintaining the same lifetime asviewModelScope:class TestScopeViewModel( val customScope: CloseableCoroutineScope = CloseableCoroutineScope() ) : ViewModel(customScope) { // You can now use customScope in the same way as viewModelScope }
আচরণগত পরিবর্তন
- Attempting to move the
Lifecycle.StatefromINITIALIZEDtoDESTROYEDwill now always throw anIllegalStateExceptionregardless of whether theLifecyclehas an attached observer. -
LifecycleRegistrywill now clear their observers when they reach theDESTROYEDstate.
Version 2.5.0-rc02
June 15, 2022
androidx.lifecycle:lifecycle-*:2.5.0-rc02 is released. Version 2.5.0-rc02 contains these commits.
Bug Fixes
-
ViewModelProviderwill no longer crash when mixing previous versions of compileOnly Lifecycle dependencies with versions 2.5+. ( I81a66 , b/230454566 )
Version 2.5.0-rc01
১১ মে, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-rc01 is released. Version 2.5.0-rc01 contains these commits.
Bug Fixes
-
MediatorLiveData.addSource()now throws aNullPointerExceptionwhen passed anullsource instead of propagating thenullsource to observers.( Ibd0fb , b/123085232 )
Version 2.5.0-beta01
April 20, 2022
androidx.lifecycle:lifecycle-*:2.5.0-beta01 is released. Version 2.5.0-beta01 contains these commits.
API Changes
- Added
SavedStateHandle.saveableproperty delegates to use property names as keys for persisting state into theSavedStateHandle( I8bb86 , b/225014345 )
Bug Fixes
- Fixed an issue where nesting one
NavHostwithin anotherNavHostin a non-primary bottom navigation tab would lead to anIllegalStateExceptionwhen using multiple back stacks. ( I11bd5 , b/228865698 )
Version 2.5.0-alpha06
৬ এপ্রিল, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha06 is released. Version 2.5.0-alpha06 contains these commits.
নতুন বৈশিষ্ট্য
- Add experimental
MutableStateoverload toSavedStateHandle.saveablefor parity withrememberSaveable( I38cfe , b/224565154 )
API Changes
-
CreationExtrasis now abstract instead of sealed. ( Ib8a7a )
Bug Fixes
- Fixed an
IllegalStateException: Already attached to lifecycleOwnererror caused bySavedStateHandleController. ( I7ea47 , b/215406268 )
Version 2.5.0-alpha05
২৩ মার্চ, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha05 is released. Version 2.5.0-alpha05 contains these commits.
নতুন বৈশিষ্ট্য
- The
lifecycle-viewmodel-composemodule now providesSavedStateHandleSaver, an experimental API that ensures values in aSavedStateHandleare integrated correctly with the same saved instance state thatrememberSaveableuses. ( Ia88b7 , b/195689777 )
API Changes
- Fixed a compatibility issue with Lifecycle 2.3 and newer Lifecycle versions in Java. ( I52c8a , b/219545060 )
Bug Fixes
-
SavedStateViewFactorynow supports usingCreationExtraseven when it was initialized with aSavedStateRegistryOwner. If extras are provided, the initialized arguments are ignored. ( I6c43b , b/224844583 )
Version 2.5.0-alpha04
March 9, 2022
androidx.lifecycle:lifecycle-*:2.5.0-alpha04 is released. Version 2.5.0-alpha04 contains these commits.
API Changes
-
SavedStateHandlenow offers agetStateFlow()API that returns a KotlinStateFlowfor monitoring value changes as an alternative to usingLiveData. ( Iad3ab , b/178037961 )
Version 2.5.0-alpha03
February 23, 2022
androidx.lifecycle:lifecycle-*:2.5.0-alpha03 is released. Version 2.5.0-alpha03 contains these commits.
নতুন বৈশিষ্ট্য
- Added an
addCloseable()API and a new constructor overload that allow you to add one or moreCloseableobjects to theViewModelthat will be closed when theViewModelis cleared without requiring any manual work inonCleared(). ( I55ea0 ) -
lifecycle-viewmodelnow provides anInitializerViewModelFactorythat allows you to add lambda for handling particularViewModelclasses, usingCreationExtrasas the primary data source. ( If58fc , b/216687549 ) -
lifecycle-viewmodel-composenow offers aviewModel()API that takes a lambda factory for creating aViewModelinstance without requiring the creation of a customViewModelProvider.Factory. ( I97fbb , b/216688927 )
API Changes
- You can now create a
ViewModelwithCreationExtrasvialifecycle-viewmodel-compose. ( I08887 , b/216688927 )
আচরণগত পরিবর্তন
- Attempting to move the
Lifecycle.StatefromINITIALIZEDtoDESTROYEDwill now always throw anIllegalStateExceptionregardless of whether theLifecyclehas an attached observer. ( I7c390 , b/177924329 ) -
LifecycleRegistrywill now clear their observers when they reach theDESTROYEDstate. ( I4f8dd , b/142925860 )
Version 2.5.0-alpha02
৯ ফেব্রুয়ারী, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha02 is released. Version 2.5.0-alpha02 contains these commits.
API Changes
-
SavedStateHandleandSavedStateViewModelFactoryhave been converted to Kotlin. This has improved the nullability of the generics in both classes. ( Ib6ce2 , b/216168263 , I9647a , b/177667711 ) - The
LiveDataswitchMapfunction parameter can now have a nullable output. ( I40396 , b/132923666 ) - The
LiveData-ktx extensions are now annotated with@CheckResultto enforce that the result is used when calling these functions. ( Ia0f05 , b/207325134 )
আচরণগত পরিবর্তন
-
SavedStateHandlenow properly stores the defaultValue when no value for the specified key exists. ( I1c6ce , b/178510877 )
Bug Fixes
- From Lifecycle
2.4.1: Updatedlifecycle-processto depend on Startup 1.1.1 to ensure that fixes that preventProcessLifecycleInitializerfrom throwing aStartupExceptionare available by default. ( Ib01df , b/216490724 ) - There is now an improved error message when custom
AndroidViewModelclasses have parameters in the wrong order and attempt to create aViewModel. ( I340f7 , b/177667711 ) - You can now create a view model via
CreationExtrasusing theAndroidViewModelFactorywithout setting an application. ( I6ebef , b/217271656 )
Version 2.5.0-alpha01
২৬ জানুয়ারী, ২০২২
androidx.lifecycle:lifecycle-*:2.5.0-alpha01 is released. Version 2.5.0-alpha01 contains these commits.
ViewModel CreationExtras
With this release, we are laying the groundwork for restructuring how a ViewModel is constructed. Instead of a rigid set of subclasses of ViewModelProvider.Factory that each add additional functionality (allowing an Application constructor parameter via AndroidViewModelFactory , allowing a SavedStateHandle constructor parameter via SavedStateViewModelFactory and AbstractSavedStateViewModelFactory , etc.), we are moving to a world of stateless factories that rely on a new concept, CreationExtras . ( Ia7343 , b/188691010 , b/188541057 )
With this change, ViewModelProvider no longer makes direct calls into the previous create(Class<T>) method of ViewModelProvider.Factory . Instead, it calls into a new overload of create : create(Class<T>, CreationExtras) . This means that any direct implementation of the ViewModelProvider.Factory instance now has access to each of these new CreationExtras :
-
ViewModelProvider.NewInstanceFactory.VIEW_MODEL_KEY: thisStringprovides access to the custom key you passed toViewModelProvider.get(). -
ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEYprovides access to theApplicationclass. -
SavedStateHandleSupport.SAVED_STATE_REGISTRY_OWNER_KEYprovides access to theSavedStateRegistryOwnerthat is being used to construct this ViewModel. -
SavedStateHandleSupport.VIEW_MODEL_STORE_OWNER_KEYprovides access to theViewModelStoreOwnerthat is being used to construct this ViewModel. -
SavedStateHandleSupport.DEFAULT_ARGS_KEYprovides access to theBundleof arguments that should be used to construct aSavedStateHandle.
These extras are provided by default when using Activity 1.5.0-alpha01 , Fragment 1.5.0-alpha01 , and Navigation 2.5.0-alpha01 . If you use an earlier version of those libraries, your CreationExtras will be empty - all of the existing subclasses of ViewModelProvider.Factory have been rewritten to support both the legacy creation path used by earlier versions of those libraries and the CreationExtras path which will be used going forward.
These CreationExtras allow you to construct a ViewModelProvider.Factory that passes just the information you need to each ViewModel without relying on a strict hierarchy of Factory subclasses:
class CustomFactory : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T {
return when (modelClass) {
HomeViewModel::class -> {
// Get the Application object from extras
val application = checkNotNull(extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY])
// Pass it directly to HomeViewModel
HomeViewModel(application)
}
DetailViewModel::class -> {
// Create a SavedStateHandle for this ViewModel from extras
val savedStateHandle = extras.createSavedStateHandle()
DetailViewModel(savedStateHandle)
}
else -> throw IllegalArgumentException("Unknown class $modelClass")
} as T
}
}
We use the createSavedStateHandle() Kotlin extension function on CreationExtras from SavedStateHandleSupport to construct a SavedStateHandle only for the one ViewModel that needs it. ( Ia6654 , b/188541057 )
Custom CreationExtras can be provided by overriding getDefaultViewModelCreationExtras() in your ComponentActivity or Fragment , thus making them available to your custom ViewModelProvider.Factory as a built in form of assisted injection. These extras will automatically be made available to your custom Factory when used directly with ViewModelProvider or when using the by viewModels() and by activityViewModels() Kotlin property extensions. ( I79f2b , b/207012584 , b/207012585 , b/207012490 )
Bug Fixes
- Fixed an issue where the default value provided to a
SavedStateHandlewould reappear after process death and recreation, even if it was specifically removed from theSavedStateHandle. As a consequence of this,SavedStateHandlewill no longer merge default values and restored values together, instead only using the restored values as the source of truth. ( I53a4b )
Version 2.4
Version 2.4.1
৯ ফেব্রুয়ারী, ২০২২
androidx.lifecycle:lifecycle-*:2.4.1 is released. Version 2.4.1 contains these commits.
Bug Fixes
- Backported from Lifecycle
2.5.0-alpha01: Fixed an issue where the default value provided to aSavedStateHandlewould re-appear after process death and recreation, even if it was specifically removed from theSavedStateHandle. As a consequence of this,SavedStateHandlewill no longer merge default values and restored values together, instead only using the restored values as the source of truth. ( I53a4b ) -
lifecycle-processnow depends on Androidx Startup 1.1.1 which fixed a regression in where usingProcessLifecycleInitializerwould cause anStartupException. ( b/216490724 )
সংস্করণ 2.4.0
২৭ অক্টোবর, ২০২১
androidx.lifecycle:lifecycle-*:2.4.0 is released. Version 2.4.0 contains these commits.
Important changes since 2.3.0
-
@OnLifecycleEventwas deprecated.LifecycleEventObserverorDefaultLifecycleObservershould be used instead. -
androidx.lifecycle:lifecycle-viewmodel-composelibrary was added. It providesviewModel()composable andLocalViewModelStoreOwner.- Source-breaking change :
ViewModelProviderhas been rewritten in Kotlin.ViewModelProvider.Factory.createmethod no longer allows nullable generic.
- Source-breaking change :
- New coroutines API were added to
androidx.lifecycle:lifecycle-runtime-ktx: -
Lifecycle.repeatOnLifecycle, API that executes a block of code in a coroutine when the Lifecycle is at least in a certain state. The block will cancel and re-launch as the lifecycle moves in and out of the target state; -
Flow.flowWithLifecycle, API that emits values from the upstream Flow when the lifecycle is at least in a certain state. -
DefaultLifecycleObserverwas moved fromlifecycle.lifecycle-common-java8tolifecycle.lifecycle-common.lifecycle.lifecycle-common-java8doesn't provide anymore any additional functionality on top oflifecycle.lifecycle-common, so dependency on it can be replaced bylifecycle.lifecycle-common. - Non coroutines API from
lifecycle-viewmodel-ktxhave been moved to thelifecycle-viewmodelmodule. lifecycle-processnow usesandroidx.startupto initialize theProcessLifecycleOwner.Previously, this was being done by
androidx.lifecycle.ProcessLifecycleOwnerInitializer.If you used
tools:node="remove"theContentProviderbeing used to initialize process lifecycle in the past, then you need to do the following instead.<provider android:name="androidx.startup.InitializationProvider" android:authorities=\"${applicationId}.androidx-startup" android:exported="false" tools:node=\"merge"> <!-- If you are using androidx.startup to initialize other components --> <meta-data android:name="androidx.lifecycle.ProcessLifecycleInitializer" android:value="androidx.startup" tools:node="remove" /> </provider>(অথবা)
<!-- If you want to disable androidx.startup completely. --> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" tools:node="remove"> </provider>
Version 2.4.0-rc01
September 29, 2021
androidx.lifecycle:lifecycle-*:2.4.0-rc01 is released with no changes from Lifecycle 2.4.0-beta01. Version 2.4.0-rc01 contains these commits.
Version 2.4.0-beta01
১৫ সেপ্টেম্বর, ২০২১
androidx.lifecycle:lifecycle-*:2.4.0-beta01 is released. Version 2.4.0-beta01 contains these commits.
API Changes
-
@OnLifecycleEventwas deprecated.LifecycleEventObserverorDefaultLifecycleObservershould be used instead. ( I5a8fa ) - DefaultLifecycleObserver was moved from
androidx.lifecycle.lifecycle-common-java8toandroidx.lifecycle.lifecycle-common.androidx.lifecycle.lifecycle-common-java8doesn't provide anymore any additional functionality on top ofandroidx.lifecycle.lifecycle-common, so dependency on it can be replaced byandroidx.lifecycle.lifecycle-common. ( I021aa ) - Non coroutines API from
lifecycle-viewmodel-ktxhave been moved to thelifecycle-viewmodelmodule. ( I6d5b2 )
External Contribution
Version 2.4.0-alpha03
August 4, 2021
androidx.lifecycle:lifecycle-*:2.4.0-alpha03 is released. Version 2.4.0-alpha03 contains these commits.
API Changes
- Source-breaking change : ViewModelProvider has been rewritten in Kotlin.
ViewModelProvider.Factory.createmethod no longer allows nullable generic. ( I9b9f6 )
আচরণগত পরিবর্তন
- The
Lifecycle.repeatOnLifecycle:blockis now always invoked serially when repeating execution. ( Ibab33 )
External Contribution
- Thanks chao2zhang for fixing the code snippets in the
repeatOnLifecycledocumentation. #205 .
Version 2.4.0-alpha02
June 16, 2021
androidx.lifecycle:lifecycle-*:2.4.0-alpha02 is released. Version 2.4.0-alpha02 contains these commits.
নতুন বৈশিষ্ট্য
- Added a new
RepeatOnLifecycleWrongUsagelint check tolifecycle-runtime-ktxthat detects whenrepeateOnLifecycleis incorrectly used inonStart()oronResume(). ( 706078 , b/187887400 )
API Changes
- The
LifecycleOwner.addRepeatingJobAPI is removed in favor ofLifecycle.repeatOnLifecyclethat respects structured concurrency and is easier to reason about. ( I4a3a8 ) - Make
ProcessLifecycleInitializerpublic so otherandroidx.startup.Initializers can use these as dependencies. ( I94c31 )
Bug Fixes
- Fixed an issue with the
NullSafeMutableLiveDatalint check when the field has modifiers. ( #147 , b/183696616 ) - Fixed another issue with the
NullSafeMutableLiveDatalint check when using generics. ( #161 , b/184830263 )
External Contribution
- Thanks maxsav for improving the
NullSafeMutableLiveDatalint check. ( #147 , b/183696616 ) - Thanks kozaxinan for improving the
NullSafeMutableLiveDatalint check. ( #161 , b/184830263 )
Version 2.4.0-alpha01
২৪ মার্চ, ২০২১
androidx.lifecycle:lifecycle-*:2.4.0-alpha01 is released. Version 2.4.0-alpha01 contains these commits.
আচরণগত পরিবর্তন
lifecycle-processnow usesandroidx.startupto initialize theProcessLifecycleOwner.Previously, this was being done by
androidx.lifecycle.ProcessLifecycleOwnerInitializer.If you used
tools:node="remove"theContentProviderbeing used to initialize process lifecycle in the past, then you need to do the following instead.<provider android:name="androidx.startup.InitializationProvider" android:authorities=\"${applicationId}.androidx-startup" android:exported="false" tools:node=\"merge"> <!-- If you are using androidx.startup to initialize other components --> <meta-data android:name="androidx.lifecycle.ProcessLifecycleInitializer" android:value="androidx.startup" tools:node="remove" /> </provider>(অথবা)
<!-- If you want to disable androidx.startup completely. --> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" tools:node="remove"> </provider>
API Changes
- Added a
Flow.flowWithLifecycleAPI that emits values from the upstream Flow when the lifecycle is at least in a certain state using theLifecycle.repeatOnLifecycleAPI. This is an alternative to the also newLifecycleOwner.addRepeatinJobAPI. ( I0f4cd )
Bug Fixes
- From Lifecycle 2.3.1 : The
NonNullableMutableLiveDatalint rule can now properly differentiate between field variables with different nullability. ( b/169249668 )
Lifecycle Viewmodel Compose Version 1.0.0
Version 1.0.0-alpha07
June 16, 2021
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07 is released. Version 1.0.0-alpha07 contains these commits.
Breaking API Changes
-
viewModel()now takes an optionalViewModelStoreOwner, making it easier to work with owners other than theLocalViewModelStoreOwner. For example, you can now useviewModel(navBackStackEntry)to retrieve a ViewModel associated with a particular navigation graph. ( I2628d , b/188693123 )
Version 1.0.0-alpha06
June 2, 2021
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha06 is released. Version 1.0.0-alpha06 contains these commits.
Updated to be compatible with Compose version 1.0.0-beta08 .
Version 1.0.0-alpha05
১৮ মে, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05 is released. Version 1.0.0-alpha05 contains these commits.
নতুন বৈশিষ্ট্য
- Updated to be compatible with Compose version
1.0.0-beta07.
Bug Fixes
- The AndroidManifest files from ui-test-manifest and ui-tooling-data are now compatible with Android 12 ( I6f9de , b/184718994 )
Version 1.0.0-alpha04
৭ এপ্রিল, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.
Dependency Changes
- This version allows
androidx.hilt:hilt-navigation-composeandandroidx.navigation:navigation-composeto sync dependencies onandroidx.compose.compiler:compiler:1.0.0-beta04andandroidx.compose.runtime:runtime:1.0.0-beta04. For 1.0.0, it is required that the compiler and runtime match.
Version 1.0.0-alpha03
১০ মার্চ, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.
API Changes
-
LocalViewModelStoreOwner.currentnow returns a nullableViewModelStoreOwnerto better determine whether aViewModelStoreOwneris available in the current composition. APIs that require aViewModelStoreOwner, such asviewModel()andNavHost, still throw an exception if aViewModelStoreOwneris not set. ( Idf39a )
Lifecycle-Viewmodel-Compose Version 1.0.0-alpha02
২৪ ফেব্রুয়ারী, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.
API Changes
-
LocalViewModelStoreOwnernow has aprovidesfunctions that can be used withCompositionLocalProvider, replacing theasProvidableCompositionLocal()API. ( I45d24 )
Lifecycle-Viewmodel-Compose Version 1.0.0-alpha01
১০ ফেব্রুয়ারী, ২০২১
androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha01 is released. Version 1.0.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
- The
viewModel()composable andLocalViewModelStoreOwnerwere moved fromandroidx.compose.ui.viewinteropto this artifact in theandroidx.lifecycle.viewmodel.composepackage. ( I7a374 )
সংস্করণ 2.3.1
Lifecycle Version 2.3.1
২৪ মার্চ, ২০২১
androidx.lifecycle:lifecycle-*:2.3.1 is released. Version 2.3.1 contains these commits.
Bug Fixes
- The
NonNullableMutableLiveDatalint rule can now properly differentiate between field variables with different nullability. ( b/169249668 )
সংস্করণ 2.3.0
সংস্করণ 2.3.0
১০ ফেব্রুয়ারী, ২০২১
androidx.lifecycle:lifecycle-*:2.3.0 is released. Version 2.3.0 contains these commits.
Major changes since 2.2.0
-
SavedStateHandlesupport for non-parcelable classes :SavedStateHandlenow supports lazy serialization by allowing you to callsetSavedStateProvider()for a given key, providing aSavedStateProviderthat will get a callback tosaveState()when theSavedStateHandleis asked to save its state. See Saving non-parcelable classes . - Lifecycle Behavior Enforcement :
- LifecycleRegistry now enforces
DESTROYEDas a terminal state. -
LifecycleRegistrynow verifies that its methods are called on main thread. It was always a requirement for lifecycles of activities, fragments etc. An addition of observers from non-main threads resulted in hard to catch crashes in runtime. ForLifecycleRegistryobjects that owned by your own components, you can explicitly opt out from checks by usingLifecycleRegistry.createUnsafe(...), but then you have to ensure that a proper synchronization is in place when thisLifecycleRegistryis accessed from different threads.
- LifecycleRegistry now enforces
- Lifecycle State and Event Helpers : Added static helper methods of
downFrom(State),downTo(State),upFrom(State),upTo(State)toLifecycle.Eventfor generating theEventgiven aStateand transition direction. Added thegetTargetState()method that provides theStatethat the Lifecycle will transition to directly following theEvent. -
withStateAtLeast: AddedLifecycle.withStateAtLeastAPIs that await a lifecycle state and run a non-suspending block of code synchronously at the point of state change, then resume with the result. These APIs differ from the existingwhen*methods as they do not permit running suspending code and do not employ a custom dispatcher. ( aosp/1326081 ) -
ViewTreeAPIs : A newViewTreeLifecycleOwner.get(View)andViewTreeViewModelStoreOwner.get(View)API allows you to retrieve the containingLifecycleOwnerandViewModelStoreOwner, respectively, given aViewinstance. You must upgrade to Activity1.2.0and Fragment1.3.0, and AppCompat 1.3.0-alpha01 or higher to populate this correctly. ThefindViewTreeLifecycleOwnerandfindViewTreeViewModelStoreOwnerKotlin extensions are available inlifecycle-runtime-ktxandlifecycle-viewmodel-ktx, respectively. -
LiveData.observe()Kotlin extension deprecation : TheLiveData.observe()Kotlin extension necessary to use lambda syntax is now deprecated as it is not necessary when using Kotlin 1.4.
Version 2.3.0-rc01
১৬ ডিসেম্বর, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-rc01 is released. Version 2.3.0-rc01 contains these commits.
Bug Fixes
- The
keys()method ofSavedStateHandleis now consistent before and after the state is saved - it now includes keys previously used withsetSavedStateProvider()in addition to the keys used withset()andgetLiveData(). ( aosp/1517919 , b/174713653 )
External Contribution
- The APIs to suspend Lifecycle-aware coroutines now better handle calls to
yield(). Thanks Nicklas Ansman Giertz! ( aosp/1430830 , b/168777346 )
Version 2.3.0-beta01
১ অক্টোবর, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-beta01 is released. Version 2.3.0-beta01 contains these commits.
API Changes
- The
LiveData.observe()Kotlin extension necessary to use lambda syntax is now deprecated as it is not necessary when using Kotlin 1.4. ( I40d3f )
Bug Fixes
- Upgrade androidx to use Kotlin 1.4 ( Id6471 , b/165307851 , b/165300826 )
Documentation Changes
- The
liveDatabuilder andasLiveData()docs have been updated to include details about changing the given timeout values. ( aosp/1122324 )
Version 2.3.0-alpha07
১৯ আগস্ট, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-alpha07 is released. Version 2.3.0-alpha07 contains these commits.
Bug Fixes
- Fixed a crash issue in the
NullSafeMutableLiveDataLint check. ( aosp/1395367 )
Version 2.3.0-alpha06
July 22, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha06 is released. Version 2.3.0-alpha06 contains these commits.
নতুন বৈশিষ্ট্য
- Added static helper methods of
downFrom(State),downTo(State),upFrom(State),upTo(State)toLifecycle.Eventfor generating theEventgiven aStateand transition direction. Added thegetTargetState()method that provides theStatethat the Lifecycle will transition to directly following theEvent. ( I00887 ) - Added
Lifecycle.withStateAtLeastAPIs that await a lifecycle state and run a non-suspending block of code synchronously at the point of state change, then resume with the result. These APIs differ from the existingwhen*methods as they do not permit running suspending code and do not employ a custom dispatcher. ( aosp/1326081 )
আচরণগত পরিবর্তন
- LifecycleRegistry now enforces
DESTROYEDas a terminal state. ( I00887 ) -
LifecycleRegistrynow verifies that its methods are called on main thread. It was always a requirement for lifecycles of activities, fragments etc. An addition of observers from non-main threads resulted in hard to catch crashes in runtime. ForLifecycleRegistryobjects that owned by your own components, you can explicitly opt out from checks by usingLifecycleRegistry.createUnsafe(...), but then you have to ensure that a proper synchronization is in place when thisLifecycleRegistryis accessed from different threads ( Ie7280 , b/137392809 )
Bug Fixes
- Fixed a crash in
NullSafeMutableLiveData. ( b/159987480 ) - Fixed an
ObsoleteLintCustomCheckfor Lint checks bundled withlifecycle-livedata-core-ktx(and specificallyNullSafeMutableLiveData). ( b/158699265 )
Version 2.3.0-alpha05
২৪ জুন, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-alpha05 is released. Version 2.3.0-alpha05 contains these commits.
Bug Fixes
-
LiveDatanow better handles reentrant cases, avoiding duplicate calls toonActive()oronInactive(). ( b/157840298 ) - Fixed an issue where Lint checks would not run when using Android Studio 4.1 Canary 6 or higher. ( aosp/1331903 )
Version 2.3.0-alpha04
June 10, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha04 is released. Version 2.3.0-alpha04 contains these commits.
Bug Fixes
- Fixed a crash in the
NonNullableMutableLiveDataLint check. ( b/157294666 ) - The
NonNullableMutableLiveDataLint check now covers significantly more cases where anullvalue was set on aMutableLiveDatawith a non-null type parameter. ( b/156002218 )
Version 2.3.0-alpha03
May 20, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha03 are released. Version 2.3.0-alpha03 contains these commits.
নতুন বৈশিষ্ট্য
-
SavedStateHandlenow supports lazy serialization by allowing you to callsetSavedStateProvider()for a given key, providing aSavedStateProviderthat will get a callback tosaveState()when theSavedStateHandleis asked to save its state. ( b/155106862 ) - A new
ViewTreeViewModelStoreOwner.get(View)API allows you to retrieve the containingViewModelStoreOwnergiven aViewinstance. You must upgrade to Activity1.2.0-alpha05, Fragment1.3.0-alpha05, and AppCompat1.3.0-alpha01to populate this correctly. AfindViewModelStoreOwner()Kotlin extension has been added tolifecycle-viewmodel-ktx. ( aosp/1295522 )
Bug Fixes
- Fixed an issue that caused the
MutableLiveDataLint checks released in Lifecycle2.3.0-alpha01from being published alongside thelifecycle-livedata-core-ktxartifact. ( b/155323109 )
Version 2.3.0-alpha02
২৯ এপ্রিল, ২০২০
androidx.lifecycle:lifecycle-*:2.3.0-alpha02 is released. Version 2.3.0-alpha02 contains these commits.
API Changes
-
SavedStateViewModelFactorynow allows you to pass a nullApplicationto its constructor to better support cases where one is not readily available and support forAndroidViewModelis not needed. ( aosp/1285740 )
Bug Fixes
- Improved cold start performance by avoiding class verification failure on API 28 and lower devices. ( aosp/1282118 )
Version 2.3.0-alpha01
March 4, 2020
androidx.lifecycle:lifecycle-*:2.3.0-alpha01 is released. Version 2.3.0-alpha01 contains these commits.
নতুন বৈশিষ্ট্য
- A new
ViewTreeLifecycleOwner.get(View)API allows you to retrieve the containingLifecycleOwnergiven aViewinstance. You must upgrade to Activity1.2.0-alpha01and Fragment1.3.0-alpha01to populate this correctly. AfindViewTreeLifecycleOwnerKotlin extension is available inlifecycle-runtime-ktx. ( aosp/1182361 , aosp/1182956 ) - Added a new Lint check that warns you when setting a
nullvalue on aMutableLiveDatathat has been defined in Kotlin as non-null. This is available when using thelivedata-core-ktxorlivedata-ktxartifacts. ( aosp/1154723 , aosp/1159092 ) - A new
lifecycle-runtime-testingartifact is available that provides aTestLifecycleOwnerthat implementsLifecycleOwnerand provides a thread safe mutableLifecycle. ( aosp/1242438 )
বাগ সংশোধন
- The
lifecycle-runtimeartifact now has a unique package name. ( aosp/1187196 )
সংস্করণ 2.2.0
ViewModel-Savedstate Version 2.2.0
৫ ফেব্রুয়ারী, ২০২০
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0 is released. Version 2.2.0 contains these commits .
Lifecycle ViewModel SavedState now shares the same version as other Lifecycle artifacts. The behavior of 2.2.0 is identical to the behavior of 1.0.0 .
সংস্করণ 2.2.0
২২ জানুয়ারী, ২০২০
androidx.lifecycle:lifecycle-*:2.2.0 is released. Version 2.2.0 contains these commits .
Important changes since 2.1.0
- Lifecycle Coroutine Integration : The new
lifecycle-runtime-ktxartifact adds integration between Lifecycle and Kotlin coroutines. Thelifecycle-livedata-ktxhas also been expanded to take advantage of coroutines. See Use Kotlin coroutines with Architecture Components for more details. -
ViewModelProviders.of()deprecation :ViewModelProviders.of()has been deprecated. You can pass aFragmentorFragmentActivityto the newViewModelProvider(ViewModelStoreOwner)constructor to achieve the same functionality when using Fragment1.2.0. -
lifecycle-extensionsArtifact Deprecation : With the above deprecation ofViewModelProviders.of(), this release marks the deprecation of the last API inlifecycle-extensionsand this artifact should now be considered deprecated in its entirety. We strongly recommend depending on the specific Lifecycle artifacts you need (such aslifecycle-serviceif you're usingLifecycleServiceandlifecycle-processif you're usingProcessLifecycleOwner) rather thanlifecycle-extensionsas there will not be a future2.3.0release oflifecycle-extensions. - Gradle Incremental Annotation Processor : Lifecycle's annotation processor is incremental by default. If your app is written in the Java 8 programming language you can use
DefautLifecycleObserverinstead; and if it's written in the Java 7 programming language you can useLifecycleEventObserver.
Version 2.2.0-rc03
৪ ডিসেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-rc03 is released. Version 2.2.0-rc03 contains these commits .
বাগ সংশোধন
- Fixed a failure occurring when a mocked
ViewModelwas stored inViewModelStoreand queried later with default factory. - Fix a usage of
Dispatchers.Main.immediateinlaunchWhenCreatedand similar methods to be called synchronously during corresponding lifecycle event. ( aosp/1156203 )
External contributions
- Thanks to Anders Järleberg for contributing the fix! ( aosp/1156203 )
- Thanks to Vsevolod Tolstopyatov from Jetbrains for reviewing an implementation of inlined execution.
Dependency changes
- Lifecycle Extensions now depends on Fragment
1.2.0-rc03.
Version 2.2.0-rc02
৭ নভেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-rc02 is released. Version 2.2.0-rc02 contains these commits .
বাগ সংশোধন
- Fixed a bug in the proguard setup of the library that affected devices running API 28+ if the target API is below 29. ( b/142778206 )
Version 2.2.0-rc01
২৩ অক্টোবর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-rc01 is released. Version 2.2.0-rc01 contains these commits .
বাগ সংশোধন
- Fixed an issue where
launchWhenCreatedand related methods would run one frame later than the associated lifecycle method due to its use ofDispatchers.Maininstead ofDispatchers.Main.immediate. ( aosp/1145596 )
External contributions
- Thanks to Nicklas Ansman for contributing the fix! ( aosp/1145596 )
Version 2.2.0-beta01
October 9, 2019
androidx.lifecycle:lifecycle-*:2.2.0-beta01 is released. Version 2.2.0-beta01 contains these commits .
বাগ সংশোধন
- Fixed a regression introduced in Lifecycle 2.2.0-alpha05 in the ordering of
ProcessLifecycleOwnerand the activity'sLifecycleOwnermoving to started and resumed on Android 10 devices. ( aosp/1128132 ) - Fixed a regression introduced in Lifecycle
2.2.0-alpha05which would cause aNullPointerExceptionwhen using version2.0.0or2.1.0oflifecycle-process. ( b/141536990 )
Version 2.2.0-alpha05
১৮ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-alpha05 is released. Version 2.2.0-alpha05 contains these commits .
বাগ সংশোধন
- Fixed a race condition in coroutine livedata builder. b/140249349
Version 2.2.0-alpha04
৫ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-alpha04 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
-
lifecycleScope,whenCreated,whenStarted,whenResumed,viewModelScope, and the underlying implementation ofliveDatanow useDispatchers.Main.immediateinstead ofDispatchers.Main. ( b/139740492 )
External contributions
- Thanks to Nicklas Ansman for contributing the move to
Dispatchers.Main.immediate! ( aosp/1106073 )
Version 2.2.0-alpha03
৭ আগস্ট, ২০১৯
androidx.lifecycle:lifecycle-*:2.2.0-alpha03 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- Implementations of
ViewModelStoreOwnercan now optionally implementHasDefaultViewModelProviderFactoryto provide a defaultViewModelProvider.Factory. This has been done for Activity1.1.0-alpha02, Fragment1.2.0-alpha02, and Navigation2.2.0-alpha01. ( aosp/1092370 , b/135716331 )
API changes
-
ViewModelProviders.of()has been deprecated. You can pass aFragmentorFragmentActivityto the newViewModelProvider(ViewModelStoreOwner)constructor to achieve the same functionality. ( aosp/1009889 )
Version 2.2.0-alpha02
July 2, 2019
androidx.lifecycle:*:2.2.0-alpha02 is released. The commits included in this version can be found here .
API changes
- Replaced
LiveDataScope.initialValuewithLiveDataScope.latestValuewhich will track the current emitted value of theliveDatablock. - Added a new overload to the
liveDatabuilder that receivestimeoutparameter as typeDuration
Version 2.2.0-alpha01
৭ মে, ২০১৯
androidx.lifecycle:*:2.2.0-alpha01 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- This release adds new features that adds support for Kotlin coroutines for Lifecycle and LiveData. Detailed documentation on them can be found here .
ViewModel-SavedState Version 1.0.0
সংস্করণ 1.0.0
২২ জানুয়ারী, ২০২০
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0 is released. Version 1.0.0 contains these commits .
Important features in 1.0.0
- New SavedStateHandle class was added. It enables your
ViewModelclasses to access and to contribute to the saved state. This object can be received in constructor ofViewModelclass and factories provided by default by Fragments and AppCompatActivity will injectSavedStateHandleautomatically. - AbstractSavedStateViewModelFactory was added. It allows you to create custom factories for your
ViewModeland provide them access toSavedStateHandle.
ViewModel-Savedstate Version 1.0.0-rc03
৪ ডিসেম্বর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc03 is released. Version 1.0.0-rc03 contains these commits .
Dependency changes
- Lifecycle ViewModel SavedState now depends on Lifecycle
2.2.0-rc03.
Viewmodel-Savedstate Version 1.0.0-rc02
৭ নভেম্বর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc02 is released. Version 1.0.0-rc02 contains these commits .
Dependency changes
- Now depends on lifecycle
2.2.0-rc02.
ViewModel-SavedState Version 1.0.0-rc01
২৩ অক্টোবর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-rc01 is released with no changes from 1.0.0-beta01 . Version 1.0.0-rc01 contains these commits .
ViewModel-Savedstate Version 1.0.0-beta01
October 9, 2019
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-beta01 is released. Version 1.0.0-beta01 contains these commits .
বাগ সংশোধন
- Fixed an issue where accessing a SavedState ViewModel for the first time in
Activity.onActivityResult()would result in anIllegalStateException. ( b/139093676 ) - Fixed an
IllegalStateExceptionwhen usingAbstractSavedStateViewModelFactory. ( b/141225984 )
ViewModel-SavedState Version 1.0.0-alpha05
১৮ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha05 is released. Version 1.0.0-alpha05 contains these commits .
API changes
-
SavedStateViewModelFactoryno longer extendsAbstractSavedStateViewModelFactoryandSavedStateHandleis created only for ViewModels that requested have it ( aosp/1113593 )
ViewModel-SavedState Version 1.0.0-alpha03
৭ আগস্ট, ২০১৯
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha03 is released. The commits included in this version can be found here .
Breaking Changes
-
lifecycle-viewmodel-savedstateno longer depends onfragmentand the relatedSavedStateViewModelFactory(Fragment)andSavedStateViewModelFactory(FragmentActivity)constructors have been removed. Instead,SavedStateViewModelFactoryis now the default factory for Activity1.1.0-alpha02, Fragment1.2.0-alpha02, and Navigation2.2.0-alpha01. ( b/135716331 )
ViewModel-SavedState Version 1.0.0-alpha02
July 2, 2019
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha02 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- Added
SavedStateHandle.getLiveData()overload which accepts a default value.
API Changes
-
SavedStateVMFactoryis renamed toSavedStateViewModelFactory. -
AbstractSavedStateVMFactoryis renamed toAbstractSavedStateViewModelFactory.
ViewModel-Savedstate Version 1.0.0-alpha01
March 13, 2019
androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01 is released. The full commit log for this initial release can be found here .
নতুন বৈশিষ্ট্য
- Now
ViewModelscan contribute to savedstate. To do that you use newly introduced viewmodel's factorySavedStateVMFactoryand your ViewModel should have a constructor that receivesSavedStateHandleobject as a parameter.
সংস্করণ 2.1.0
Important changes since 2.0.0
- Added
LifecycleEventObserverfor the cases when a stream of lifecycle events is needed. It is a public API instead of a hiddenGenericLifecycleObserverclass. - Added ktx extensions for
LiveData.observemethods andTransformations.*methods. - Added
Transformations.distinctUntilChanged, which creates a new LiveData object that does not emit a value until the sourceLiveDatavalue has been changed. - Added coroutine support in ViewModels by adding the extension property
ViewModel.viewModelScope.
সংস্করণ 2.1.0
৫ সেপ্টেম্বর, ২০১৯
androidx.lifecycle:lifecycle-*:2.1.0 is released. The commits included in this version can be found here .
Version 2.1.0-rc01
July 2, 2019
androidx.lifecycle:*:2.1.0-rc01 is released with no changes from androidx.lifecycle:*:2.1.0-beta01 . The commits included in this version can be found here .
Version 2.1.0-beta01
৭ মে, ২০১৯
androidx.lifecycle:*:2.1.0-beta01 is released. The commits included in this version can be found here .
নতুন বৈশিষ্ট্য
- Lifecycles are graduated to beta: api introduced in previous alphas such as
liveDataextension functions for transformations and observations,ViewModelinitialisation with property delegation and others are stabilised and not going to change.
Version 2.1.0-alpha04
April 3, 2019
androidx.lifecycle:*:2.1.0-alpha04 is released. The commits included in this version can be found here .
API changes
- Breaking change: the underlying API behind
by viewModels()andby activityViewModels()has been changed to support aViewModelStoredirectly, rather than only aViewModelStoreOwner. ( aosp/932932 )
Version 2.1.0-alpha03
March 13, 2019
androidx.lifecycle:*:2.1.0-alpha03 is released. The full list of commits included in this version can be found here .
API changes
-
ViewModelProvider.KeyedFactorywas removed. Second interface in addition toViewModelProvider.Factorydidn't compose well with new features as property delegation in Kotlinby viewmodels {}. ( aosp/914133 )
Version 2.1.0-alpha02
January 30, 2019
androidx.lifecycle 2.1.0-alpha02 is released.
API changes
-
LifecycleRegistrynow contains asetCurrentState()method that replaces the now deprecatedsetState()method. ( aosp/880715 )
বাগ সংশোধন
- Fixed an issue where mock
ViewModelinstances would crash when the containingViewModelStorewas cleared. b/122273087
Version 2.1.0-alpha01
১৭ ডিসেম্বর, ২০১৮
androidx.lifecycle 2.1.0-alpha01 is released.
নতুন বৈশিষ্ট্য
- Added
LifecycleEventObserverfor the cases when a stream of lifecycle events is needed. It is a public api instead of a hiddenGenericLifecycleObserverclass. - Added ktx extensions for
LiveData.observemethods andTransformations.*methods. - Method
Transformations.distinctUntilChangedwas added. It creates a newLiveDataobject that does not emit a value until the source LiveData value has been changed. - Coroutine support in ViewModels: extension property
ViewModel.viewModelScopewas added. - Added
ViewModelProvider.KeyedFactory, a factory for ViewModels that receiveskeyandClassincreatemethod.
সংস্করণ 2.0.0
সংস্করণ 2.0.0
September 21, 2018
Lifecycle 2.0.0 is released with one bugfix from 2.0.0-rc01 in ViewModel.
Bug Fixes
- Fixed a ViewModel proguard rule that incorrectly removed constructors b/112230489
Version 2.0.0-beta01
July 2, 2018
Bug Fixes
- Fixed LifecycleObserver proguard rule to keep only implementations, not subinterfaces b/71389427
- Fixed ViewModel proguard rules to allow obfuscation and shrinking
Pre-AndroidX Versions
For the pre-AndroidX versions of Lifecycle that follow, include these dependencies:
dependencies {
def lifecycle_version = "1.1.1"
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
// alternatively - just ViewModel
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version" // For Kotlin use viewmodel-ktx
// alternatively - just LiveData
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
// alternatively - Lifecycles only (no ViewModel or LiveData).
// Support library depends on this lightweight import
implementation "android.arch.lifecycle:runtime:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version" // For Kotlin use kapt instead of annotationProcessor
// alternately - if using Java8, use the following instead of compiler
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
// optional - ReactiveStreams support for LiveData
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
// optional - Test helpers for LiveData
testImplementation "android.arch.core:core-testing:$lifecycle_version"
}
Version 1.1.1
March 21, 2018
Only one small change: android.arch.core.util.Function is moved from arch:runtime to arch:common . This allows it to be used without the runtime dependency, eg in paging:common below.
lifecycle:common is a dependency of lifecycle:runtime , so this change doesn't affect lifecycle:runtime directly, only modules that depend directly on lifecycle:common , as Paging does.
সংস্করণ 1.1.0
January 22, 2018
Packaging Changes
New, much smaller dependencies are now available:
-
android.arch.lifecycle:livedata:1.1.0 -
android.arch.lifecycle:viewmodel:1.1.0
API Changes
- The deprecated
LifecycleActivityandLifecycleFragmenthave now been removed - please useFragmentActivity,AppCompatActivityor supportFragment. -
@NonNullannotations have been added toViewModelProvidersandViewModelStores -
ViewModelProvidersconstructor has been deprecated - please use its static methods directly -
ViewModelProviders.DefaultFactoryhas been deprecated - please useViewModelProvider.AndroidViewModelFactory - The static
ViewModelProvider.AndroidViewModelFactory.getInstance(Application)method has been added to retrieve a staticFactorysuitable for creatingViewModelandAndroidViewModelinstances.