Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
Thanks for reporting this, it'll try to get a fix for it soon.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 4aefd0eb39e533f473b2da27fa00703d31d31ee7
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jul 08 11:46:34 2020
Use reflection name for Worker and ViewModel multibinding keys.
Worker factories search for an assisted factory based on the
reflection name of the class and not its canonical name,
e.g. TopClass$NestedWorker vs TopClass.NestedWorker. This
changes fixes the generated multibinding key (@StringKey) so that
the reflection name is used and nested Worker classes get
instantiated by Hilt. Furthermore to keep the keys consistent,
this change updates HiltViewModelFactory to also use the
reflection name.
Bug: 160524718
Test: Hilt Worker and ViewModel test apps.
Change-Id: I3f9255c2e8601fbf7cb2c0160c4e6aae2fe6c58f
M hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelGenerator.kt
M hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerGenerator.kt
M hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelGeneratorTest.kt
M hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/HiltViewModelFactory.java
M hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/ActivityInjectionTest.kt
M hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/MyViewModels.kt
M hilt/integration-tests/workerapp/src/androidTest/java/androidx/hilt/integration/workerapp/SimpleTest.kt
M hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
https://android-review.googlesource.com/1358763
Branch: androidx-master-dev
commit 4aefd0eb39e533f473b2da27fa00703d31d31ee7
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Wed Jul 08 11:46:34 2020
Use reflection name for Worker and ViewModel multibinding keys.
Worker factories search for an assisted factory based on the
reflection name of the class and not its canonical name,
e.g. TopClass$NestedWorker vs TopClass.NestedWorker. This
changes fixes the generated multibinding key (@StringKey) so that
the reflection name is used and nested Worker classes get
instantiated by Hilt. Furthermore to keep the keys consistent,
this change updates HiltViewModelFactory to also use the
reflection name.
Bug: 160524718
Test: Hilt Worker and ViewModel test apps.
Change-Id: I3f9255c2e8601fbf7cb2c0160c4e6aae2fe6c58f
M hilt/hilt-compiler/src/main/kotlin/androidx/hilt/lifecycle/ViewModelGenerator.kt
M hilt/hilt-compiler/src/main/kotlin/androidx/hilt/work/WorkerGenerator.kt
M hilt/hilt-compiler/src/test/kotlin/androidx/hilt/lifecycle/ViewModelGeneratorTest.kt
M hilt/hilt-lifecycle-viewmodel/src/main/java/androidx/hilt/lifecycle/HiltViewModelFactory.java
M hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/ActivityInjectionTest.kt
M hilt/integration-tests/viewmodelapp/src/androidTest/java/androidx/hilt/integration/viewmodelapp/MyViewModels.kt
M hilt/integration-tests/workerapp/src/androidTest/java/androidx/hilt/integration/workerapp/SimpleTest.kt
M hilt/integration-tests/workerapp/src/main/java/androidx/hilt/integration/workerapp/SimpleWorker.kt
da...@google.com <da...@google.com> #4
A fix for this issue will be available in alpha02
Description
Component used: Fragment Version used: Devices/Android versions reproduced on:
When using Hilt Jetpack integration, the Hilt Work factory failed to create Worker with the following exception:
It appears this is due to a but in the class name mapping.
I declared my worker inside a Kotlin object like this:
Which create a
com.example.webservices.Device.Worker
entry in the Worker Factory mapping. But this entry do not match the real runtime class name which iscom.example.webservices.Device$Worker