Verified
Status Update
Comments
[Deleted User] <[Deleted User]> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 66494e2d6810347e6a3b41ec3f2665e598f108f0
Author: Ian Lake <ilake@google.com>
Date: Thu Apr 14 00:14:24 2022
Ensure that SavedStateHandle restores upon initial creation
runOnNextRecreation() only runs on the next time
the lifecycle reaches CREATED, not the first time.
By using a LifecycleObserver directly, we ensure that
each Lifecycle move causes a performRestore() to
consistently happen.
Test: existing tests pass, sample app works
BUG: 228865698
Relnote: "Fixed an issue where nesting one `NavHost` within
another `NavHost` in a non-primary bottom navigation tab
would lead to an `IllegalStateException` when using
multiple back stacks."
Change-Id: I11bd5173f035ae1da7922b4142fcedc0f3b54ff6
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandleSupport.kt
https://android-review.googlesource.com/2064518
Branch: androidx-main
commit 66494e2d6810347e6a3b41ec3f2665e598f108f0
Author: Ian Lake <ilake@google.com>
Date: Thu Apr 14 00:14:24 2022
Ensure that SavedStateHandle restores upon initial creation
runOnNextRecreation() only runs on the next time
the lifecycle reaches CREATED, not the first time.
By using a LifecycleObserver directly, we ensure that
each Lifecycle move causes a performRestore() to
consistently happen.
Test: existing tests pass, sample app works
BUG: 228865698
Relnote: "Fixed an issue where nesting one `NavHost` within
another `NavHost` in a non-primary bottom navigation tab
would lead to an `IllegalStateException` when using
multiple back stacks."
Change-Id: I11bd5173f035ae1da7922b4142fcedc0f3b54ff6
M lifecycle/lifecycle-viewmodel-savedstate/src/main/java/androidx/lifecycle/SavedStateHandleSupport.kt
da...@gmail.com <da...@gmail.com> #3
Thanks for quick fix! Works well with latest snapshot.
[Deleted User] <[Deleted User]> #4
Thanks for confirming! The fix will be in the next release of Lifecycle (2.5.0-beta01).
[Deleted User] <[Deleted User]> #5
2.4.1 also has same issue
using jetpack compose / bottom navigation with NavHost
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
using jetpack compose / bottom navigation with NavHost
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
da...@gmail.com <da...@gmail.com> #6
I am seeing a high occurance rate with 2.5.0-beta01 as well.
vi...@google.com <vi...@google.com>
vi...@google.com <vi...@google.com> #7
Re remember
around getBackStackEntry
needs to be updated.
[Deleted User] <[Deleted User]> #8
Hi, I recently came across this crash in my current project and I discovered that it happens when a Textfield was tapped and in focus, then the app was backgrounded. This would occur with all of the Textfields in the app.
We are using Compose version: 1.2.0-rc03
and jetpack lifecycle version: 2.4.1
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
We are using Compose version: 1.2.0-rc03
and jetpack lifecycle version: 2.4.1
Fatal Exception: java.lang.IllegalStateException: You cannot access the NavBackStackEntry's ViewModels after the NavBackStackEntry is destroyed.
at androidx.navigation.NavBackStackEntry.getViewModelStore(NavBackStackEntry.kt:192)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:106)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:69)
da...@gmail.com <da...@gmail.com> #9
Please file a new bug with a minimal sample project that reproduces your error.
vi...@google.com <vi...@google.com> #10
Okay, we will get a sample project up soon. One thing I forgot to mention in the initial comment is that this crash occurs when we use backQueue.clear() to clear the back stack. We were able to come up with a solution/workaround by using popUpTo() as a way to clear the back stack, and after implementing that solution we saw no crashes when backgrounding the app while a textfield was in focus.
cc...@google.com <cc...@google.com> #11
Re backQueue
is not part of the public API surface and never has been. Calling anything on that is always, always, always the wrong thing to do.
ve...@google.com <ve...@google.com> #12
Any updates? This issue is persistent for almost 6 months and its getting crazier.
Description
Theme used: Theme.AppCompat.Light.DarkActionBar or Theme.MaterialComponents
Devices/Android versions reproduced on: irrelevant. (Tested on Nokia 8 Android 8.1, Nokia 7 Plus Android P beta 04)
I'm testing the method AppCompatTextView.setTextFuture but I realized, it didn't support layout direction (android:layoutDirection="rtl") from righ to left (RTL) or on a device has the system language shows from RTL as the Arabic language, even I removed the attr android:layoutDirection="rtl". The app will crash. Please test again.
java.lang.IllegalArgumentException: Given text can not be applied to TextView.
at androidx.core.widget.TextViewCompat.setPrecomputedText(TextViewCompat.java:889)
at androidx.appcompat.widget.AppCompatTextView.consumeTextFutureAndSetBlocking(AppCompatTextView.java:468)
at androidx.appcompat.widget.AppCompatTextView.onMeasure(AppCompatTextView.java:500)
at android.view.View.measure(View.java:22112)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22112)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:22112)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at androidx.appcompat.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:401)
at android.view.View.measure(View.java:22112)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22112)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22112)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:875)
at android.view.View.measure(View.java:22112)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2426)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1508)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1765)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1396)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6773)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:978)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:964)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
-------------------------------------------------
Source code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
xmlns:tools="
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
android:layoutDirection="rtl"
tools:context=".MainActivity">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
------------------------------------------------------------------------
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val textView = findViewById<AppCompatTextView>(R.id.textView);
setAsyncText(textView, "Testing the setTextFuture method ")
}
private fun setAsyncText(textView: AppCompatTextView, text: String?) {
if (!text.isNullOrEmpty()) {
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, TextViewCompat.getTextMetricsParams(textView), null)
textView.setTextFuture(textFuture) // Crash
//textView.text = text // No crash
//textView.setPrecomputedText(PrecomputedTextCompat.create(text, textView.textMetricsParamsCompat)) // No crash
}
}
}
--------------------------------------------------------------
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
--------------------------------------
My device
Android Studio 3.3 Canary 6
Build #AI-182.3684.101.33.4954005, built on August 15, 2018
JRE: 1.8.0_152-release-1136-b06 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha06'
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.61"
}