Rxjava: App Crash when ObserveOn Android main thread

Created on 28 Jun 2020  路  2Comments  路  Source: ReactiveX/RxJava

Issue
I try to implement observeOn AndroidSchedulers.mainThread() But it always crash
if I remove this line it working fine

   myObservable = Observable.fromArray(intArray);
   myObservable.subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread()).
     subscribeWith(getObserver());

Error Log

    java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
    at io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.<clinit>(AndroidSchedulers.java:33)
    at io.reactivex.rxjava3.android.schedulers.AndroidSchedulers.mainThread(AndroidSchedulers.java:44)
    at com.example.rxjavasample.SecondActivity.onCreate(SecondActivity.java:38)

Gradle dependencies

implementation "io.reactivex.rxjava3:rxjava:3.0.4"
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
3.x Android Question

Most helpful comment

You probably have to set your project to Java 8 mode:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

All 2 comments

You probably have to set your project to Java 8 mode:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

yes its fixed

Was this page helpful?
0 / 5 - 0 ratings