tbruyelle / RxPermissions

Android runtime permissions powered by RxJava2
Apache License 2.0
10.48k stars 1.31k forks source link

support for rxjava2.0.1 #163

Closed prazjain closed 6 years ago

prazjain commented 7 years ago

Hi, I get compilation error when I try to do this: rxPermission.request(Manifest.permission.READ_CONTACTS) .observeOn(AndroidSchedulers.mainThread()) .subscribe(granted -> ......);

The error is on observeOn line, saying : Error:(177, 56) error: incompatible types: io.reactivex.Scheduler cannot be converted to rx.Scheduler

mrArtCore commented 7 years ago

Hi @prazjain Maybe you should to read error carefully ??? Looks like you are using RxJava1 and Rxjava2 in the project. And at line (177, 56) you try to use rx.Scheduler instead of io.reactivex.Scheduler ???

prazjain commented 7 years ago

my project is using: compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.0.1'

When I look at build.gradle for rxpermissions then I see this : rxJava = 'io.reactivex:rxjava:1.2.9'

mrArtCore commented 7 years ago

And what is the version of this library do you use? And why don't you use version with Rx java2 support? Check out main page of the project

prazjain commented 7 years ago

I am using this : 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'

I have just noticed there is a rxjava2 support version as well : 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'

I will give it a try tonight.

prazjain commented 7 years ago

I have tried rxjava2 version and it still fails. I think the problem here is that RxPermissions.request(...) method is returning a Observable from rxjava-1.1.6, and thats why chained observeOn method which passes AndroidScheduler.mainThread() is not compatible with that object.

mrArtCore commented 7 years ago

@prazjain You just use wrong scheduler with whatever RxPermission instance version you have. Profile your imports, dependencies and use correct versions of RxJava and RxAndroid.

BTW, there is no Observable from rxjava-1.1.6 In "com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar" dependency. You doing something wrong. Library works fine !