Status Update
Comments
il...@google.com <il...@google.com>
nd...@gmail.com <nd...@gmail.com> #2
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
st...@gmail.com <st...@gmail.com> #3
ap...@google.com <ap...@google.com> #4
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
cl...@google.com <cl...@google.com> #5
Fixed and available in the release on Aug 21st.
st...@gmail.com <st...@gmail.com> #6
It looks like I can still repro the same bug with snapshots from 12208038 and navigation dependency version 2.8.0-SNAPSHOT
.
This is the project
This commit shows the changes I've added which was to add the enum to one of the destinations.
This still crashes with
java.lang.IllegalArgumentException: Cannot find class with name "com.stylianosgakis.predictive_navigation_repro.B.SomeEnum". Ensure that the serialName for this argument is the default fully qualified name
at W0.b.c(Unknown Source:81)
...
It is very important to run this with isMinifyEnabled = true
, since this only happens in release builds that are minified, and therefore the names are changed which introduces this bug as I understand.
st...@gmail.com <st...@gmail.com> #7
Very good point made by Ian, adding @androidx.annotation.Keep
to the enum makes it not crash again, since r8 no longer mangles the name, and serialization and the real name then start matching again.
cl...@google.com <cl...@google.com> #8
Re:
I git cloned your main branch from
Tried running as is, with SomeEnum
nested inside B
, no crashes. I then moved your enum class out of B
@Serializable
data class B(val someEnum: SomeEnum)
enum class SomeEnum {
A, B;
}
So now its using snapshot, minified = true, top level Enum, no crashes.
cl...@google.com <cl...@google.com> #9
Ah yes I see the crash in release build. As Ian recommended, use @androidx.annotation.Keep
or else the class gets removed.
st...@gmail.com <st...@gmail.com> #10
Created a new issue
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 6187e05a8c1892c1679aa4571e5a5d6ffb9663e8
Author: Clara Fok <clarafok@google.com>
Date: Fri Aug 09 09:26:44 2024
Improve error message for Enum type
Navigation added built-in support for Enums in type safety. Due to limited metadata without kotlin reflect, the implementation relies on the Enum's serialName to match the Enum class's fqn.
However, if r8 minifed build is employed in release builds, it is possible that the fqn is modified. Kotlinx serialization is not aware of this, however, and the serialName would remain the same. This means navigation won't be able to match the serialName to the new fqn.
The current solution is to add @androidx.annotation.Keep on enum classes to ensure it doesn't get erased. We should update the exception message to suggest this as a possible solution.
Test: ./gradlew navigation:navigation-common:cC
Bug: 358137294
Relnote: "Update Enum class not found exception to suggest using @Keep annotation in case the Enum class gets erased in minified builds."
Change-Id: I90e79cc476c21ab0ad3b172af65c436817665ef7
M navigation/navigation-common/src/main/java/androidx/navigation/serialization/NavTypeConverter.kt
M navigation/navigation-common/src/test/java/androidx/navigation/serialization/NavArgumentGeneratorTest.kt
na...@google.com <na...@google.com> #12
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-common:2.8.0-rc01
androidx.navigation:navigation-runtime:2.8.0-rc01
sa...@outlook.com <sa...@outlook.com> #13
Looks like the above suggestion to update the exception to add the Keep annotation would be a good idea.
ch...@gmail.com <ch...@gmail.com> #14
@Serializable
data class NewReservationDetails(val usage: Usage) {
companion object {
val typeMap = mapOf(typeOf<Usage>() to NavType.EnumType<Usage>(Usage::class.java))
fun from(savedStateHandle: SavedStateHandle) =
savedStateHandle.toRoute<Usage>(typeMap)
}
}
composable<NewReservationDetails>(
enterTransition = { expandHorizontally() },
exitTransition = { shrinkHorizontally() },
typeMap = NewReservationDetails.typeMap
) { backStackEntry ->
val parentEntry = remember(backStackEntry) {
navController.getBackStackEntry(NewReservation)
}
val parentViewModel: OrderRideHostViewModel = hiltViewModel(parentEntry)
val viewModel: OrderRideAddressDateViewModel = hiltViewModel()
NewReservationDetailsScreen(
orderRideAddressDateViewModel = viewModel,
orderRideHostViewModel = parentViewModel
)
}
)
class OrderRideAddressDateViewModel @Inject constructor(
val savedStateHandle: SavedStateHandle,
) : ViewModel() {
private val usage = NewReservationDetails.from(savedStateHandle)
}
I'm still having the crash, i've tried a lot of thing :(
java.lang.IllegalArgumentException: Cannot cast PERSO of type com.wimova.domain.model.Usage.PERSO to a NavType. Make sure to provide custom NavType for this argument.
il...@google.com <il...@google.com> #15
Re
na...@google.com <na...@google.com> #16
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-common:2.9.0-alpha01
Description
Component used: Navigation Version used: Version 2.8.0-beta07 Devices/Android versions reproduced on: Pixel 6Pro Android14 The release notes for Version 2.8.0-beta07 state that there is not need to explicitly provide a typeMap for Enum classes but the App crashes on startup but works as expected if the typeMap is provided or the enum class is nested inside the destination serializable data class.
this one works
but this one fails
If this is a bug in the library, we would appreciate if you could attach: