TooManyEduardos
TooManyEduardos

Reputation: 4394

RxJava and RxAndroid - Do I need both?

There's a similar question here, but it doesn't really answer the question.

I've been using RxJava and RxAndroid in my Android application, and now the project works.

Then I removed RxJava and only left RxAndroid, and the project continues to work. However, I don't know enough about RxJava and RxAndroid to know if leaving just RxAndroid would be missing things in the long run.

Everything I read about RxAndroid is that it is an extension of RxJava, but is this a true extension in the sense of having everything RxJava has + some Android specific stuff (like AndroidSchedulers)?

Would I need both anyways? Are there downsides of keeping both dependencies?

Thank you.

Upvotes: 1

Views: 1236

Answers (2)

zsxwing
zsxwing

Reputation: 20816

You can only declare RxAndroid, and RxJava will be pulled as it's a transitive dependency.

However, you can find the following comment in RxAndroid's README:

RxAndroid releases are few and far between, it is recommended you also explicitly depend on RxJava's latest version for bug fixes and new features.

If you add RxJava to your dependencies, you can upgrade RxJava anytime if you need some important fixes or features, and don't need to wait for RxAndroid's new release.

Upvotes: 7

AndroidEx
AndroidEx

Reputation: 15824

I assume you use Gradle build system for you Android project, and in this case you question has actually more to do with it than with RxJava or RxAndroid.

Let's say you have two dependencies in your build.gradle file: RxJava and RxAndroid. When you remove your RxJava dependency, Gradle will still look into RxAndroid dependencies to figure out what it depends on transitively.

RxAndroid:1.1.0 depends on RxJava:1.1.0. So if the line you removed explicitly specified that you want RxJava:1.1.2 in your project, it's going to be downgraded back to 1.1.2 -> 1.1.0.

Upvotes: 1

Related Questions