Dims
Dims

Reputation: 51249

class file for org.reactivestreams.Publisher not found while compiling example from RxJava?

The following code

package com.inthemoon.snippets.rxjava;

import io.reactivex.*;

public class HelloWorld {

   public static void main(String[] args) {
      Flowable.just("Hello world").subscribe(System.out::println);
   }

}

causes the following compile error

Error:(9, 15) java: cannot access org.reactivestreams.Publisher class file for org.reactivestreams.Publisher not found

POM dependency is following

<dependencies>
        <!-- https://mvnrepository.com/artifact/io.reactivex.rxjava2/rxjava -->
        <dependency>
            <groupId>io.reactivex.rxjava2</groupId>
            <artifactId>rxjava</artifactId>
            <version>2.0.4</version>
        </dependency>


    </dependencies>

Upvotes: 7

Views: 18447

Answers (3)

Ivan Vovk
Ivan Vovk

Reputation: 1039

Same error and simple solution - add this to your app Gradle file

implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

Upvotes: 15

Laurent Perez
Laurent Perez

Reputation: 668

This has been fixed since 2.0.5 by github.com/ReactiveX/RxJava/issues/5014 2.1.1, is the latest version as of this answer

Solution :

    <dependency>
        <groupId>io.reactivex.rxjava2</groupId>
        <artifactId>rxjava</artifactId>
        <version>2.1.1</version>
    </dependency>

Upvotes: 4

KingJA
KingJA

Reputation: 59

The same happened to me.I have solved it. add the dependeny follows:

<dependency>
    <groupId>org.reactivestreams</groupId>
    <artifactId>reactive-streams</artifactId>
    <version>1.0.0</version>
</dependency>

Upvotes: 4

Related Questions