Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
ri...@ffw.com <ri...@ffw.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
el...@google.com <el...@google.com> #4
Thank you for promptly replying to my report. You are right that the issue you've just mentioned is similar to mine. I shall continue observing the progress over there.
ak...@gmail.com <ak...@gmail.com> #5
I still have the same issue on iOS with room version 2.7.0 alpha03
da...@google.com <da...@google.com>
va...@gmail.com <va...@gmail.com> #6
Hi i was searching for these I have the same issue recursiveFetchLongSparseArray for 2.7.0 alpha03 and under :
```
@Transaction
@Query("SELECT * FROM person_local WHERE uid = :uid")
fun getPersonWithFilesByUid(uid: Long): Flow<PeopleWithFiles>
```
```
import androidx.room.Embedded
import androidx.room.Relation
data class PeopleWithFiles(
@Embedded val person: Person,
@Relation(
parentColumn = "uid",
entityColumn = "personUid"
)
val filesEntity: List<PeopleFileEntity> = emptyList()
) {
fun toFilePaths(): List<String> {
return filesEntity.map { it.filePath }
}
}
```
```
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(
tableName = "person_local_files",
foreignKeys = [
ForeignKey(
entity = Person::class,
parentColumns = ["uid"],
childColumns = ["personUid"],
onDelete = ForeignKey.CASCADE
)
],
indices = [Index(value = ["personUid"])] // Add this line
)
data class PeopleFileEntity(
@PrimaryKey(autoGenerate = true) val fileId: Long = 0,
@ColumnInfo(name = "personUid") val personUid: Long,
@ColumnInfo(name = "filePath") val filePath: String,
@ColumnInfo(name = "fileTag") val fileTag: String
)
```
> Task :composeApp:compileKotlinIosArm64 FAILED
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:13:27: error: Unresolved reference: recursiveFetchLongSparseArray
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:675:7: error: Unresolved reference: recursiveFetchLongSparseArray
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:675:51: error: Cannot infer a type for this parameter. Please specify it explicitly.
The import import androidx.room.util.recursiveFetchLongSparseArray
``` private
fun __fetchRelationshippersonLocalFilesAsdatabasePeopleFileEntity(_connection: SQLiteConnection,
_map: LongSparseArray<MutableList<PeopleFileEntity>>) {
if (_map.isEmpty()) {
return
}
if (_map.size() > 999) {
recursiveFetchLongSparseArray(_map, true) { _tmpMap ->
__fetchRelationshippersonLocalFilesAsdatabasePeopleFileEntity(_connection, _tmpMap)
}
return
}
```
I attach the builded file
```
@Transaction
@Query("SELECT * FROM person_local WHERE uid = :uid")
fun getPersonWithFilesByUid(uid: Long): Flow<PeopleWithFiles>
```
```
import androidx.room.Embedded
import androidx.room.Relation
data class PeopleWithFiles(
@Embedded val person: Person,
@Relation(
parentColumn = "uid",
entityColumn = "personUid"
)
val filesEntity: List<PeopleFileEntity> = emptyList()
) {
fun toFilePaths(): List<String> {
return filesEntity.map { it.filePath }
}
}
```
```
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
@Entity(
tableName = "person_local_files",
foreignKeys = [
ForeignKey(
entity = Person::class,
parentColumns = ["uid"],
childColumns = ["personUid"],
onDelete = ForeignKey.CASCADE
)
],
indices = [Index(value = ["personUid"])] // Add this line
)
data class PeopleFileEntity(
@PrimaryKey(autoGenerate = true) val fileId: Long = 0,
@ColumnInfo(name = "personUid") val personUid: Long,
@ColumnInfo(name = "filePath") val filePath: String,
@ColumnInfo(name = "fileTag") val fileTag: String
)
```
> Task :composeApp:compileKotlinIosArm64 FAILED
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:13:27: error: Unresolved reference: recursiveFetchLongSparseArray
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:675:7: error: Unresolved reference: recursiveFetchLongSparseArray
/Users/vaxela/Documents/projects/test/Room-CMP/composeApp/build/generated/ksp/iosArm64/iosArm64Main/kotlin/database/PeopleDao_Impl.kt:675:51: error: Cannot infer a type for this parameter. Please specify it explicitly.
The import import androidx.room.util.recursiveFetchLongSparseArray
``` private
fun __fetchRelationshippersonLocalFilesAsdatabasePeopleFileEntity(_connection: SQLiteConnection,
_map: LongSparseArray<MutableList<PeopleFileEntity>>) {
if (_map.isEmpty()) {
return
}
if (_map.size() > 999) {
recursiveFetchLongSparseArray(_map, true) { _tmpMap ->
__fetchRelationshippersonLocalFilesAsdatabasePeopleFileEntity(_connection, _tmpMap)
}
return
}
```
I attach the builded file
de...@gmail.com <de...@gmail.com> #7
el...@google.com <el...@google.com>
el...@google.com <el...@google.com> #9
Hi there! We were able to reproduce and fix the issue on our end. Should be fixed in the next release of Room.
de...@gmail.com <de...@gmail.com> #10
Thank you!
I am looking to make use of room asap. When can we expect the next release of Room?
I am looking to make use of room asap. When can we expect the next release of Room?
el...@google.com <el...@google.com> #11
Should be late June or early July!
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #12
Project: platform/frameworks/support
Branch: androidx-main
commit fd4a29dca9fcd48555399ec9f018e8caf603d075
Author: elifbilgin <elifbilgin@google.com>
Date: Thu May 30 13:49:02 2024
Resolve invalid Relation codegen.
Users were encountering a "missing recursiveFetchLongSparseArray()" error in
codegen for iOS. This issue was due to the fact that room-runtime was not
depending on androidx.collection in common. Now that androidx.collection is
available in KMP (and, therefore, LongSparseArray is available) we can
depend on it in room-runtime.
This issue was reproduced and verified by adding the androidx.collection
dependency to the common source set of the kotlin multiplatform test app
and using existing tests that use @Relation on the iOS target. Once verified, the
dependency was added to room-runtime common source sets, and the
`recursiveFetchLongSparseArray()` function has been moved from the
Android-only RelationUtil.android.kt to the common RelationUtil.kt.
Bug: 341002184
Test: BaseQueryTest.kt
Change-Id: Id1afde6c5eeb46c3fe0bf9cc14c52eccb161be72
M room/room-runtime/build.gradle
M room/room-runtime/src/androidMain/kotlin/androidx/room/util/RelationUtil.android.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/util/RelationUtil.kt
https://android-review.googlesource.com/3128794
Branch: androidx-main
commit fd4a29dca9fcd48555399ec9f018e8caf603d075
Author: elifbilgin <elifbilgin@google.com>
Date: Thu May 30 13:49:02 2024
Resolve invalid Relation codegen.
Users were encountering a "missing recursiveFetchLongSparseArray()" error in
codegen for iOS. This issue was due to the fact that room-runtime was not
depending on androidx.collection in common. Now that androidx.collection is
available in KMP (and, therefore, LongSparseArray is available) we can
depend on it in room-runtime.
This issue was reproduced and verified by adding the androidx.collection
dependency to the common source set of the kotlin multiplatform test app
and using existing tests that use @Relation on the iOS target. Once verified, the
dependency was added to room-runtime common source sets, and the
`recursiveFetchLongSparseArray()` function has been moved from the
Android-only RelationUtil.android.kt to the common RelationUtil.kt.
Bug: 341002184
Test: BaseQueryTest.kt
Change-Id: Id1afde6c5eeb46c3fe0bf9cc14c52eccb161be72
M room/room-runtime/build.gradle
M room/room-runtime/src/androidMain/kotlin/androidx/room/util/RelationUtil.android.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/util/RelationUtil.kt
va...@hotmail.fr <va...@hotmail.fr> #13
I have a question it will be release with alpha 05 ?
el...@google.com <el...@google.com> #14
Yes, this fix will be included in androidx.room:2.7.0-alpha05.
ri...@ffw.com <ri...@ffw.com> #15
The same issue happens on desktop target, does this fix all targets?
el...@google.com <el...@google.com> #16
Thanks for letting us know - Yes, the fix covers all targets.
lz...@gmail.com <lz...@gmail.com> #17
Do you have a release schedule?
el...@google.com <el...@google.com> #18
Yes, we plan on having it land with the July 10th, 2024 release.
na...@google.com <na...@google.com> #19
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-runtime:2.7.0-alpha05
androidx.room:room-runtime-android:2.7.0-alpha05
androidx.room:room-runtime-iosarm64:2.7.0-alpha05
androidx.room:room-runtime-iossimulatorarm64:2.7.0-alpha05
androidx.room:room-runtime-iosx64:2.7.0-alpha05
androidx.room:room-runtime-jvm:2.7.0-alpha05
androidx.room:room-runtime-linuxx64:2.7.0-alpha05
androidx.room:room-runtime-macosarm64:2.7.0-alpha05
androidx.room:room-runtime-macosx64:2.7.0-alpha05
Description
Version used: 2.7.0-alpha01/02
Sample project:
Add the following Relation
```
data class TeamWithPlayers(
@Embedded val team: Team,
@Relation(
parentColumn = "id",
entityColumn = "id",
entity = Player::class,
)
val players: List<Player>,
)
```
Add the following to the FantasyPremierLeagueDao
```
@Query("SELECT * FROM Team")
@Transaction
fun getTeamsWithPlayers(): Flow<List<TeamWithPlayers>>
```
Result:
> Task :common:compileKotlinIosSimulatorArm64 FAILED
/../FantasyPremierLeague/common/build/generated/ksp/iosSimulatorArm64/iosSimulatorArm64Main/kotlin/dev/johnoreilly/common/database/FantasyPremierLeagueDao_Impl.kt:11:27: error: Unresolved reference: recursiveFetchLongSparseArray
/../FantasyPremierLeague/common/build/generated/ksp/iosSimulatorArm64/iosSimulatorArm64Main/kotlin/dev/johnoreilly/common/database/FantasyPremierLeagueDao_Impl.kt:395:7: error: Unresolved reference: recursiveFetchLongSparseArray
/../FantasyPremierLeague/common/build/generated/ksp/iosSimulatorArm64/iosSimulatorArm64Main/kotlin/dev/johnoreilly/common/database/FantasyPremierLeagueDao_Impl.kt:395:51: error: Cannot infer a type for this parameter. Please specify it explicitly.
I know id wouldn't match, I just want to show that parentColumn and entityColumn something other than String will result in this. Same with id being an actual Long value. If I change parentColumn and entityColumn to use "name", it works as both are Strings and it uses "recursiveFetchMap" instead of "recursiveFetchLongSparseArray"