Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda