Fixed
Status Update
Comments
ch...@google.com <ch...@google.com>
ch...@google.com <ch...@google.com> #2
Project: platform/frameworks/support
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
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
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
yq...@gmail.com <yq...@gmail.com> #3
ch...@google.com <ch...@google.com> #4
Project: platform/frameworks/support
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 ( b/140759491 ).
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
https://android-review.googlesource.com/1288456
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
yq...@gmail.com <yq...@gmail.com> #5
Thanks for the detailed response.
Do I need to add the above rule in my proguard file?
I thought the above rule should be added to proguard file in the android platform module.
I've searched platform source code, and found the following rule placed in savedstate module.
https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/savedstate/proguard-rules.pro
I think
"SavedStateRegistry.AutoRecreated"
should be changed to
"SavedStateRegistry$AutoRecreated".
Please correct me if I'm wrong, thanks!
Do I need to add the above rule in my proguard file?
I thought the above rule should be added to proguard file in the android platform module.
I've searched platform source code, and found the following rule placed in savedstate module.
I think
"SavedStateRegistry.AutoRecreated"
should be changed to
"SavedStateRegistry$AutoRecreated".
Please correct me if I'm wrong, thanks!
ch...@google.com <ch...@google.com> #6
Yes, it should. We will make sure that the keep rule in androidx gets updated (I will keep this issue open until the rules have been fixed there).
I also filed a feature request b/132860232 to ensure that R8 will actually raise a warning when a type name in the Proguard configuration is using '.' for the inner class name separator instead of '$'.
I also filed a feature request
ch...@google.com <ch...@google.com> #7
Sergey, could you help make the appropriate changes to the keep rule mentioned in comment #5 ?
sg...@google.com <sg...@google.com> #8
I did some digging into the androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha01 library, and it turns out that they already supply this keep rule from the library:
-keepclassmembers,allowobfuscation class * extends androidx.savedstate.SavedStateRegistry.AutoRecreated {
<init>();
}
However, that is using the fully qualified and not the binary name of the AutoRecreated inner class.
I will create a CL, so that going forward using androidx.lifecycle:lifecycle-viewmodel-savedstate should not require additional keep rules.
-keepclassmembers,allowobfuscation class * extends androidx.savedstate.SavedStateRegistry.AutoRecreated {
<init>();
}
However, that is using the fully qualified and not the binary name of the AutoRecreated inner class.
I will create a CL, so that going forward using androidx.lifecycle:lifecycle-viewmodel-savedstate should not require additional keep rules.
sg...@google.com <sg...@google.com> #9
ar...@gmail.com <ar...@gmail.com> #10
Gg
Description
androidx.lifecycle: 2.2.0-alpha01
<Steps to reproduce>
1. Based on new empty activity project, add following ViewModel class.
```
class MainViewModel(
private val savedStateHandle: SavedStateHandle
): ViewModel()
```
2. Modify MainActivity as followings.
```
class MainActivity : AppCompatActivity() {
private lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
viewModel = ViewModelProviders.of(
this,
SavedStateVMFactory(this)
).get(MainViewModel::class.java)
}
}
```
3. Add a keep rule for MainViewModel.
-keep class com.example.savedstateviewmodelsample.MainViewModel { *; }
4. Enable r8 fullMode and run app, then the app crash with the following error.
com.example.savedstateviewmodelsample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.savedstateviewmodelsample, PID: 15365
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.savedstateviewmodelsample/com.example.savedstateviewmodelsample.MainActivity}: java.lang.IllegalArgumentException: ClassOnRecreation must have default constructor in order to be automatically recreated
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.IllegalArgumentException: ClassOnRecreation must have default constructor in order to be automatically recreated
at androidx.savedstate.SavedStateRegistry.runOnNextRecreation(:177)
at androidx.lifecycle.AbstractSavedStateVMFactory.create(:71)
at androidx.lifecycle.ViewModelProvider.get(:162)
at androidx.lifecycle.ViewModelProvider.get(:130)
at com.example.savedstateviewmodelsample.MainActivity.onCreate(:20)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NoSuchMethodException: <init> []
at java.lang.Class.getConstructor0(Class.java:2327)
at java.lang.Class.getDeclaredConstructor(Class.java:2166)
at androidx.savedstate.SavedStateRegistry.runOnNextRecreation(:175)
at androidx.lifecycle.AbstractSavedStateVMFactory.create(:71)
at androidx.lifecycle.ViewModelProvider.get(:162)
at androidx.lifecycle.ViewModelProvider.get(:130)
at com.example.savedstateviewmodelsample.MainActivity.onCreate(:20)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)