Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
Unable to use Autodispose in Android with Kotlin

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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:

com.android.support:appcompat-v7 -> androidx.appcompat:appcompat:1.0.0

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.

Version 1.0.0 2018-10-10 Stable release! This is identical in functionality to 1.0.0-RC3 but completely migrated to the new AndroidX artifacts. From this point forward for Android projects, you must be on AndroidX artifacts. You can use 1.0.0-RC3 to ease migration if need be.

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!