Amira Elsayed Ismail
Amira Elsayed Ismail

Reputation: 9394

RxJava android not working and can't compile code

I want to learn RXjava for android, so I have done the following:

1) I have downloaded the jar file of rxandroid-0.24.jar , rxandroid-framework-0.24.jar
2) added files to libs folder in android studio
3) add lib dependency to android studio, please check following screenshot:

enter image description here

4) tried some code in my fragment and it doesn't seem to see rxandroid, please check following code:

import rx.Observable;
public class AboutFragment extends Fragment {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Observable.from("one","two","three","four","five")
        .subscribeOn(Schedulers.newThread())
        .observeOn(AndroidSchedulers.mainThread())
        .sobscribe(/* an Observer */);
}

I am using this tutorial https://github.com/ReactiveX/RxJava/wiki/The-RxJava-Android-Module

Can anyone please help and tell me what is missing here?

Upvotes: 0

Views: 2509

Answers (1)

Adam S
Adam S

Reputation: 16394

You're missing the import for the Android schedulers; they're in a different package to the rest of RxJava:

import rx.android.schedulers.AndroidSchedulers;

Upvotes: 3

Related Questions