Fixed
Status Update
Comments
se...@google.com <se...@google.com>
jb...@google.com <jb...@google.com> #2
Looks to be the same issue as https://github.com/androidannotations/androidannotations/issues/1208 where after being parceled and unparceled, the type swaps to Parcelable[] which is indeed a different type than CustomModel[]. The same thing can be seen with Fragment destinations if you:
1. turn on the Developer Option of "Don't keep activities"
2. Navigate to the Fragment destination (it won't crash)
3. Hit the home button
4. Use the recents button to relaunch the app (it will crash)
It seems like the only viable work around is to create a new array of the correct type (CustomModel[]), then System.arraycopy() the objects over. We can do this automatically as part of the Args class. We should also double check to see if this same problem exists with Serializable.
1. turn on the Developer Option of "Don't keep activities"
2. Navigate to the Fragment destination (it won't crash)
3. Hit the home button
4. Use the recents button to relaunch the app (it will crash)
It seems like the only viable work around is to create a new array of the correct type (CustomModel[]), then System.arraycopy() the objects over. We can do this automatically as part of the Args class. We should also double check to see if this same problem exists with Serializable.
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 72631a760ebfb23990c42440d0c1f8c67fafe5ed
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Thu Feb 07 14:11:06 2019
Copy & Cast Parcelable array items when reading NavArgs from Bundle
Bundle#getParcelableArray() return Parcelable[] which NavArgs was
failing to cast to Item[] where Item is an app defined Parcelable. This
CL changes the generated code so that the Parcelable[] items are copied
into an array of the defined type in the nav graph.
This issue doesn't exist for Serializable since there is no
Bundle#getSerializableArray().
Bug: 123963545
Test: Manual test with sample app provided in issue.
Change-Id: Ibfcb703a1ad48929a0731b82a13a1f33813187b5
M navigation/safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaTypes.kt
M navigation/safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinTypes.kt
M navigation/safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/MainFragmentArgs.java
M navigation/safe-args-generator/src/tests/test-data/expected/kotlin_nav_writer_test/MainFragmentArgs.kt
https://android-review.googlesource.com/898454
https://goto.google.com/android-sha1/72631a760ebfb23990c42440d0c1f8c67fafe5ed
Branch: androidx-master-dev
commit 72631a760ebfb23990c42440d0c1f8c67fafe5ed
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Thu Feb 07 14:11:06 2019
Copy & Cast Parcelable array items when reading NavArgs from Bundle
Bundle#getParcelableArray() return Parcelable[] which NavArgs was
failing to cast to Item[] where Item is an app defined Parcelable. This
CL changes the generated code so that the Parcelable[] items are copied
into an array of the defined type in the nav graph.
This issue doesn't exist for Serializable since there is no
Bundle#getSerializableArray().
Bug: 123963545
Test: Manual test with sample app provided in issue.
Change-Id: Ibfcb703a1ad48929a0731b82a13a1f33813187b5
M navigation/safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaTypes.kt
M navigation/safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/kotlin/KotlinTypes.kt
M navigation/safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/MainFragmentArgs.java
M navigation/safe-args-generator/src/tests/test-data/expected/kotlin_nav_writer_test/MainFragmentArgs.kt
jb...@google.com <jb...@google.com> #4
This is fixed internally and will be available in Navigation 1.0.0-beta02
de...@gmail.com <de...@gmail.com> #5
Getting this again in AGP 8.2.2 and Gradle 8.6, please see the attached image file.
de...@gmail.com <de...@gmail.com> #6
Just found out that the issue comes after updating androidx.lifecycle:lifecycle-livedata-ktx
from 2.7.0 to 2.8.0.
da...@gmail.com <da...@gmail.com> #7
Using AGP 8.5.1 with Gradle 8.7 makes the latest occurrence of this go away for me (with androidx.lifecycle:lifecycle-runtime-ktx
2.8.4).
zo...@gmail.com <zo...@gmail.com> #8
This has come back using on AGP 8.7.0-alpha09 (starting maybe with alpha05 according to my build history? maybe alpha04?).
I'm using Gradle 8.9 as well, if that matters.
Description
Component used: lifecycle-livedata-ktx
Version used: 2.3.0-alpha04
Devices/Android versions reproduced on: Android Studio 4.0 (AGP 4.0)
I get below lint warning when running
./gradlew lint
.NullSafeMutableLiveData
is not working.I'll attach the reproduction project and lint results. Please check it.
Thanks.