I'm investigating a weird issue, where we changed the androidx.appcompat:appcompat
from 1.3.1
to 1.4.1
and all of a sudden our LifecycleObservers
observing process lifecycle stopped emitting any events.
I'm also using "androidx.lifecycle:lifecycle-extensions:2.2.0"
, I know that this is already deprecated, but it works flawlessly if appcompat is 1.3.1
I have set the correct application name in the Manifest, I have included this provider as required per docs.
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />
Example of initialisation, which doesn't work. This object is injected in the Application
class and lifecycle observer is getting added, but onStart
and onStop
are never called.
class AppLifecycle @Inject constructor(
private val foregroundProxy: AppLifecycleProxy
) : LifecycleObserver {
init {
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onStart() {
foregroundProxy.onStarted()
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onStop() {
foregroundProxy.onStopped()
}
}
EDIT: As per @EpicPandaForce comment, changing the the provider block in Manifest to:
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities=\"${applicationId}.androidx-startup"
android:exported="false"
tools:node=\"merge">
<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.lifecycle.ProcessLifecycleInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
And replacing the "androidx.lifecycle:lifecycle-extensions:2.2.0"
dependency with "androidx.lifecycle:lifecycle-common:2.4.1"
has fixed this problem
1.6.0-alpha01
version? – Scammony