I was trying to use AutoDispose https://github.com/uber/AutoDispose to dispose of my Rx streams in android.
But I am having an issue when I add it to my activity/fragment. I think it is a kotlin issue but I am not able to figure out what.
when I add AndroidLifecycleScopeProvider.from(lifecycle)
I get an error on the from method in Android Studio and it won't compile.
This is the stack trace
None of the following functions can be called with the arguments supplied:
public final fun from(p0: (() -> Lifecycle)!): AndroidLifecycleScopeProvider! defined in com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
public open fun from(p0: Lifecycle!): AndroidLifecycleScopeProvider! defined in com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
public open fun from(p0: LifecycleOwner!): AndroidLifecycleScopeProvider! defined in com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
The same code works with there sample app.
I have encounter same issue, it cause by compatibility of Lifecycle package Androidx support and previous v7 support, they are different in package artifact naming.
AndroidX
Mirgration
eg: artifact naming:
AppCompatActivity implemented LifecycleOwner that is the power under AutoDispose's work, but in latest version AutoDispose, they use AndroidX instead (see AndroidLifecycleScopeProvider.from(LifecycleOwner owner) 'LifecycleOwner' ), so owner can not be treat as right type if you use Non-Androidx with AutoDispose v1.1.0(AFAIK AutoDispose v0.8.0 works well with com.android.support:appcompat-v7:28.0.0)
So, you can either use Migrate you app to AndroidX Mirgration Guide or use older version of AutoDispose. See AutoDispose on mvnrepository.
About the change, see the changelog https://github.com/uber/AutoDispose/blob/master/CHANGELOG.md#version-100 , v1.0.0 and later version depend on AndroidX, v1.0.0-RC3 should be our choice.
Edit: If you want RxKotlin like extension, go and copy: https://github.com/uber/AutoDispose/blob/master/sample/src/main/kotlin/com/uber/autodispose/recipes/subscriberproxies.kt