लातों वाला भूत
01/08/2024, 8:08 PMjava.lang.IllegalArgumentException: SavedStateProvider with the given key is already registered
This is possibly because of retainedComponent trying to recreate using the same key.
The trouble is Android allows sending deeplink intent from onNewIntent as well as onCreate.
Adding code in threadलातों वाला भूत
01/08/2024, 8:09 PM@OptIn(ExperimentalDecomposeApi::class)
fun AppCompatActivity.setUpMedialApp(
modifier: Modifier = Modifier,
deeplink: String? = null
) {
val rootComponent = retainedComponent {
RootComponentImpl(it, deeplink)
}
setContent {
MedialApp(
darkTheme = isSystemInDarkTheme(),
dynamicColor = true,
component = rootComponent,
modifier = modifier
)
}
}
लातों वाला भूत
01/08/2024, 8:10 PMoverride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
KoinConfig(this).initKoin()
Firebase.initialize(this)
checkForUpdates()
content(intent)
ExceptionHelper()
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
content(intent)
}
private fun content(intent: Intent? = null) {
setUpMedialApp(deeplink = getDeeplink(intent))
}
Arkadii Ivanov
01/08/2024, 8:47 PMThis is possibly because of retainedComponent trying to recreate using the same key.This looks like the cause,
setUpMedialApp
is being called twice.
Usually (without retained components) there are two ways of handling deeplinks.
1. In onNewIntent
, call setIntent(intent)
and then call recreate()
. And in onCreate
you can call defaultComponentContext(discardSavedState = deepLink != null)
, where deepLink
is a deeplink parsed from the Activity intent.
2. In onNewIntent
, call just call a root
component's method and pass the deeplink there. The root
component then just navigates to the required state.
The first option is preferable from my point of view. But some people actually prefer the second variant.
But since you are using retained components, currently there is no way of using the option #1 (there is no discardSavedState
argument in retainedComponent
function), only option #2 is possible. I think I could add discardSavedState
to retainedComponent
function. What do you think?लातों वाला भूत
01/08/2024, 8:58 PMलातों वाला भूत
01/08/2024, 8:59 PMArkadii Ivanov
01/08/2024, 9:01 PMretainedComponent
API. Filed https://github.com/arkivanov/Decompose/issues/588लातों वाला भूत
01/08/2024, 9:04 PMलातों वाला भूत
01/09/2024, 6:39 AMलातों वाला भूत
01/11/2024, 7:41 AMArkadii Ivanov
01/11/2024, 8:58 AMArkadii Ivanov
01/11/2024, 8:58 AMलातों वाला भूत
01/11/2024, 9:22 AMलातों वाला भूत
01/11/2024, 9:22 AMArkadii Ivanov
01/11/2024, 9:26 AMArkadii Ivanov
01/11/2024, 9:27 AMArkadii Ivanov
01/11/2024, 9:30 AMArkadii Ivanov
01/11/2024, 9:31 AMलातों वाला भूत
01/11/2024, 9:33 AMलातों वाला भूत
01/11/2024, 9:33 AMVaibhav Jaiswal
01/11/2024, 11:59 AMdiscardSavedState
It still crashes with the same errorArkadii Ivanov
01/11/2024, 12:08 PMArkadii Ivanov
01/11/2024, 12:10 PMVaibhav Jaiswal
01/11/2024, 12:23 PMonNewIntent()
to this
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
recreate()
}
Now its not crashing, but navigation is reset
Checking if deeplink is there or not and doing nothing will handle the scenario when app is minimized and openedArkadii Ivanov
01/11/2024, 12:26 PMArkadii Ivanov
01/11/2024, 12:32 PMलातों वाला भूत
01/11/2024, 12:32 PMVaibhav Jaiswal
01/21/2024, 12:48 PMArkadii Ivanov
01/21/2024, 1:34 PMVaibhav Jaiswal
01/21/2024, 2:34 PMArkadii Ivanov
01/23/2024, 10:26 PMretainedComponent
function.लातों वाला भूत
01/23/2024, 11:46 PMलातों वाला भूत
01/24/2024, 9:07 AMArkadii Ivanov
01/24/2024, 9:53 AM