Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 8b868f409d5b78d15919e15a9ae1ce5aba4eca57
Author: Ian Lake <ilake@google.com>
Date: Thu Jun 20 20:37:18 2019
Remove fragment dependency from viewmodel-savedstate
Remove SavedStateVMFactory constructors that depend
on androidx.fragment to make this a more foundational
library.
Test: tests still pass
BUG: 135716331
Change-Id: I65bfc6e8b02793074623897366a548d9384ae284
M lifecycle/lifecycle-viewmodel-savedstate/api/1.0.0-alpha02.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/current.txt
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/ViewModelsWithStateTests.java
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/activity/FakingSavedStateActivity.java
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateVMFactory.java
https://android-review.googlesource.com/987584
https://goto.google.com/android-sha1/8b868f409d5b78d15919e15a9ae1ce5aba4eca57
Branch: androidx-master-dev
commit 8b868f409d5b78d15919e15a9ae1ce5aba4eca57
Author: Ian Lake <ilake@google.com>
Date: Thu Jun 20 20:37:18 2019
Remove fragment dependency from viewmodel-savedstate
Remove SavedStateVMFactory constructors that depend
on androidx.fragment to make this a more foundational
library.
Test: tests still pass
BUG: 135716331
Change-Id: I65bfc6e8b02793074623897366a548d9384ae284
M lifecycle/lifecycle-viewmodel-savedstate/api/1.0.0-alpha02.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/current.txt
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/ViewModelsWithStateTests.java
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/activity/FakingSavedStateActivity.java
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateVMFactory.java
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 4ba9e1f4bc18a1b7af28ffb88c145e4933689798
Author: Ian Lake <ilake@google.com>
Date: Fri Jun 21 09:59:11 2019
Make SavedStateVMFactory the default factory
For both ComponentActivity and Fragment,
use SavedStateVMFactory as the default factory
for constructing ViewModels.
As this is a strict superset of ViewModel constructors
now supported, any existing code assuming a ViewModel
or AndroidViewModel will continue to function.
Test: updated tests
Fixes: 135716331
Change-Id: Iadbee198c471cb245bd16727b7f817a27898ffcb
M activity/activity/build.gradle
M activity/activity/src/androidTest/java/androidx/activity/ComponentActivityViewModelTest.kt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
M fragment/fragment/build.gradle
M fragment/fragment/src/androidTest/java/androidx/fragment/app/ViewModelTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/test/ViewModelActivity.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
https://android-review.googlesource.com/987585
https://goto.google.com/android-sha1/4ba9e1f4bc18a1b7af28ffb88c145e4933689798
Branch: androidx-master-dev
commit 4ba9e1f4bc18a1b7af28ffb88c145e4933689798
Author: Ian Lake <ilake@google.com>
Date: Fri Jun 21 09:59:11 2019
Make SavedStateVMFactory the default factory
For both ComponentActivity and Fragment,
use SavedStateVMFactory as the default factory
for constructing ViewModels.
As this is a strict superset of ViewModel constructors
now supported, any existing code assuming a ViewModel
or AndroidViewModel will continue to function.
Test: updated tests
Fixes: 135716331
Change-Id: Iadbee198c471cb245bd16727b7f817a27898ffcb
M activity/activity/build.gradle
M activity/activity/src/androidTest/java/androidx/activity/ComponentActivityViewModelTest.kt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
M fragment/fragment/build.gradle
M fragment/fragment/src/androidTest/java/androidx/fragment/app/ViewModelTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/test/ViewModelActivity.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
il...@google.com <il...@google.com> #4
Reopening as the changes were reverted with the switch back to Java 7.
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b4eddfd7b427a4a334dceb6e0fb600de38ccdd4f
Author: Ian Lake <ilake@google.com>
Date: Fri Jun 21 09:59:11 2019
Make SavedStateViewModelFactory the default factory
For both ComponentActivity and Fragment,
use SavedStateViewModelFactory as the default factory
for constructing ViewModels.
As this is a strict superset of ViewModel constructors
now supported, any existing code assuming a ViewModel
or AndroidViewModel will continue to function.
Test: updated tests
BUG: 135716331
Change-Id: I86ef27e21c6d90f169217956baf9813224df4616
M activity/activity/build.gradle
M activity/activity/src/androidTest/java/androidx/activity/ComponentActivityViewModelTest.kt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
M fragment/fragment/build.gradle
M fragment/fragment/src/androidTest/java/androidx/fragment/app/ViewModelTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/test/ViewModelActivity.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
https://android-review.googlesource.com/1093193
https://goto.google.com/android-sha1/b4eddfd7b427a4a334dceb6e0fb600de38ccdd4f
Branch: androidx-master-dev
commit b4eddfd7b427a4a334dceb6e0fb600de38ccdd4f
Author: Ian Lake <ilake@google.com>
Date: Fri Jun 21 09:59:11 2019
Make SavedStateViewModelFactory the default factory
For both ComponentActivity and Fragment,
use SavedStateViewModelFactory as the default factory
for constructing ViewModels.
As this is a strict superset of ViewModel constructors
now supported, any existing code assuming a ViewModel
or AndroidViewModel will continue to function.
Test: updated tests
BUG: 135716331
Change-Id: I86ef27e21c6d90f169217956baf9813224df4616
M activity/activity/build.gradle
M activity/activity/src/androidTest/java/androidx/activity/ComponentActivityViewModelTest.kt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
M fragment/fragment/build.gradle
M fragment/fragment/src/androidTest/java/androidx/fragment/app/ViewModelTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/test/ViewModelActivity.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit a5581d7561fccdb2b2ca9a0af2fdb2318086d254
Author: Ian Lake <ilake@google.com>
Date: Mon Jul 29 12:34:35 2019
Remove fragment dependency from viewmodel-savedstate, v2
Remove SavedStateVMFactory constructors that depend
on androidx.fragment to make this a more foundational
library.
Test: tests still pass
BUG: 135716331
Change-Id: Ieaa7a5012c3c5d832b0dbeec74b499e09688c43f
M lifecycle/lifecycle-viewmodel-savedstate/api/1.0.0-alpha03.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/current.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/restricted_1.0.0-alpha03.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/restricted_current.txt
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/ViewModelsWithStateTests.java
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateViewModelFactory.java
https://android-review.googlesource.com/1093191
https://goto.google.com/android-sha1/a5581d7561fccdb2b2ca9a0af2fdb2318086d254
Branch: androidx-master-dev
commit a5581d7561fccdb2b2ca9a0af2fdb2318086d254
Author: Ian Lake <ilake@google.com>
Date: Mon Jul 29 12:34:35 2019
Remove fragment dependency from viewmodel-savedstate, v2
Remove SavedStateVMFactory constructors that depend
on androidx.fragment to make this a more foundational
library.
Test: tests still pass
BUG: 135716331
Change-Id: Ieaa7a5012c3c5d832b0dbeec74b499e09688c43f
M lifecycle/lifecycle-viewmodel-savedstate/api/1.0.0-alpha03.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/current.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/restricted_1.0.0-alpha03.txt
M lifecycle/lifecycle-viewmodel-savedstate/api/restricted_current.txt
M lifecycle/lifecycle-viewmodel-savedstate/build.gradle
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/SavedStateFactoryTest.kt
M lifecycle/lifecycle-viewmodel-savedstate/src/androidTest/java/androidx/lifecycle/viewmodel/savedstate/ViewModelsWithStateTests.java
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateViewModelFactory.java
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 5371f5bebc24934cf16e63643184d37e9847777a
Author: Ian Lake <ilake@google.com>
Date: Mon Jul 29 16:00:58 2019
Make SavedStateViewModelFactory default for Navigation
For NavController's getViewModelStoreOwner(),
make the default Factory a SavedStateViewModelFactory.
As this is a strict superset of ViewModel constructors
now supported, any existing code assuming a ViewModel
or AndroidViewModel will continue to function.
Test: updated tests
BUG: 135716331
Change-Id: I43faa405dc43c3a43e01d20c42e7758e4627c08f
M navigation/navigation-runtime/build.gradle
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavBackStackEntry.java
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavBackStackEntryState.java
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.java
https://android-review.googlesource.com/1092240
https://goto.google.com/android-sha1/5371f5bebc24934cf16e63643184d37e9847777a
Branch: androidx-master-dev
commit 5371f5bebc24934cf16e63643184d37e9847777a
Author: Ian Lake <ilake@google.com>
Date: Mon Jul 29 16:00:58 2019
Make SavedStateViewModelFactory default for Navigation
For NavController's getViewModelStoreOwner(),
make the default Factory a SavedStateViewModelFactory.
As this is a strict superset of ViewModel constructors
now supported, any existing code assuming a ViewModel
or AndroidViewModel will continue to function.
Test: updated tests
BUG: 135716331
Change-Id: I43faa405dc43c3a43e01d20c42e7758e4627c08f
M navigation/navigation-runtime/build.gradle
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavBackStackEntry.java
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavBackStackEntryState.java
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.java
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 0e5ee7959df8875c07b081d2e74aeacc3d1b1dfe
Author: Ian Lake <ilake@google.com>
Date: Tue Jul 30 12:38:15 2019
Use default factory for navGraphViewModels()
Ensure that navGraphViewModels() works as
expected with SavedState ViewModels so that it
uses the correct default factory associated
with the navigation graph.
Test: new test passes
BUG: 135716331
Change-Id: Ia2f3790a045103b6a889069e00794222ea8eac52
M navigation/navigation-fragment-ktx/build.gradle
M navigation/navigation-fragment-ktx/src/androidTest/AndroidManifest.xml
M navigation/navigation-fragment-ktx/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
A navigation/navigation-fragment-ktx/src/androidTest/res/layout/activity_nav_graph.xml
A navigation/navigation-fragment-ktx/src/androidTest/res/navigation/vm_graph.xml
M navigation/navigation-fragment-ktx/src/main/java/androidx/navigation/NavGraphViewModelLazy.kt
https://android-review.googlesource.com/1092471
https://goto.google.com/android-sha1/0e5ee7959df8875c07b081d2e74aeacc3d1b1dfe
Branch: androidx-master-dev
commit 0e5ee7959df8875c07b081d2e74aeacc3d1b1dfe
Author: Ian Lake <ilake@google.com>
Date: Tue Jul 30 12:38:15 2019
Use default factory for navGraphViewModels()
Ensure that navGraphViewModels() works as
expected with SavedState ViewModels so that it
uses the correct default factory associated
with the navigation graph.
Test: new test passes
BUG: 135716331
Change-Id: Ia2f3790a045103b6a889069e00794222ea8eac52
M navigation/navigation-fragment-ktx/build.gradle
M navigation/navigation-fragment-ktx/src/androidTest/AndroidManifest.xml
M navigation/navigation-fragment-ktx/src/androidTest/java/androidx/navigation/fragment/NavGraphViewModelLazyTest.kt
A navigation/navigation-fragment-ktx/src/androidTest/res/layout/activity_nav_graph.xml
A navigation/navigation-fragment-ktx/src/androidTest/res/navigation/vm_graph.xml
M navigation/navigation-fragment-ktx/src/main/java/androidx/navigation/NavGraphViewModelLazy.kt
il...@google.com <il...@google.com> #9
As part of this change:
- the SavedStateViewModelFactory(Fragment) and SavedStateViewModelFactory(FragmentActivity) constructors have been removed (as viewmodel-savedstate no longer depends on Fragments)
- When you use the ViewModelProvider(ViewModelStoreOwner) constructor or ViewModelProviders.of() with an Activity / Fragment / Navigation Graph ViewModelStoreOwner, you'll be using the correct SavedStateViewModelFactory - no custom factory is needed
- When you use the Kotlin property delegates such as 'by viewModels()', 'by activityViewModels()' or 'by navGraphViewModels()', you'll be using the correct SavedStateViewModelFactory - again, no custom factory needed
This will be part of:
- androidx.lifecycle viewmodel 2.2.0-alpha03
- androidx.lifecycle viewmodel-savedstate 1.0.0-alpha03
- androidx.activity 1.1.0-alpha02
- androidx.fragment 1.2.0-alpha02
- androidx.navigation 2.2.0-alpha01
- the SavedStateViewModelFactory(Fragment) and SavedStateViewModelFactory(FragmentActivity) constructors have been removed (as viewmodel-savedstate no longer depends on Fragments)
- When you use the ViewModelProvider(ViewModelStoreOwner) constructor or ViewModelProviders.of() with an Activity / Fragment / Navigation Graph ViewModelStoreOwner, you'll be using the correct SavedStateViewModelFactory - no custom factory is needed
- When you use the Kotlin property delegates such as 'by viewModels()', 'by activityViewModels()' or 'by navGraphViewModels()', you'll be using the correct SavedStateViewModelFactory - again, no custom factory needed
This will be part of:
- androidx.lifecycle viewmodel 2.2.0-alpha03
- androidx.lifecycle viewmodel-savedstate 1.0.0-alpha03
- androidx.activity 1.1.0-alpha02
- androidx.fragment 1.2.0-alpha02
- androidx.navigation 2.2.0-alpha01
da...@gmail.com <da...@gmail.com> #10
It seems like this change causes an exception such as:
Fatal Exception: java.lang.IllegalArgumentException
SavedStateProvider with the given key is already registered
Using the latest fragment/architecture component dependencies.
I am using "by activityViewModels" to get my viewModel, and "requireActivity().viewModelStore.clear()" to destroy it. Then, when getting the viewmodel is called again, it crashes because of the mentioned exception.
Fatal Exception: java.lang.IllegalArgumentException
SavedStateProvider with the given key is already registered
Using the latest fragment/architecture component dependencies.
I am using "by activityViewModels" to get my viewModel, and "requireActivity().viewModelStore.clear()" to destroy it. Then, when getting the viewmodel is called again, it crashes because of the mentioned exception.
il...@google.com <il...@google.com> #11
Re #10 - please file a new bug with a sample project that reproduces your issue.
Description
Version used: 2.2.0-alpha01
Most components, such as ComponentActivity and Fragment, seem to use AndroidViewModelFactory as the default factory. It would be great if the default could be updated to be a SavedStateVMFactory as it offers strictly more functionality.