badoo / MVICore

MVI framework with events, time-travel, and more
https://badoo.github.io/MVICore/
Other
1.27k stars 90 forks source link

Troubles with using MVICore while using RxJava 3.x. #128

Open MairwunNx opened 4 years ago

MairwunNx commented 4 years ago

Error message providing me by IDEA:

Cannot access 'io.reactivex.ObservableSource' which is a supertype of 'com.example.androidbasics.fragments.FirstFragmentFeature'. 
Check your module classpath for missing or conflicting dependencies

And the same one more errors in same class but with different "can't access":

Cannot access 'io.reactivex.functions.Consumer'
Cannot access 'io.reactivex.disposables.Disposable' 

It also shown randomly, for example, I just formatter file or add any symbol and code analyzer do wakeup :).

Deps related probably to this issue:

    implementation "io.reactivex.rxjava3:rxkotlin:$rxkotlin_version"
    implementation "io.reactivex.rxjava3:rxandroid:$rxandroid_version"
    implementation "io.reactivex.rxjava3:rxjava:$rxjava_version"

where rxkotlin_version, rxandroid_version is 3.0.0 and rxjava_version is 3.0.4

Fragment state to reproduce (some lines formatted to in-line): it's pure boilerplate code

class FirstFragmentFeature : ReducerFeature<Wish, State, Nothing>(
    initialState = State(), reducer = ReducerImpl()
) {
    data class State(val counter: Int = 0)

    sealed class Wish {
        object IncreaseCounter : Wish()
        data class MultiplyBy(val value: Int) : Wish()
    }

    class ReducerImpl : Reducer<State, Wish> {
        override fun invoke(state: State, wish: Wish): State {
            return when (wish) {
                Wish.IncreaseCounter -> state.copy(counter = state.counter + 1)
                is Wish.MultiplyBy -> state.copy(counter = state.counter * wish.value)
            }
        }
    }
}

Installed mvicore dependencies (in app/build.gradle): used 1.2.4 version

    implementation "com.github.badoo.mvicore:mvicore:${mvicore_version}"
    implementation "com.github.badoo.mvicore:mvicore-android:${mvicore_version}"
    implementation "com.github.badoo.mvicore:mvicore-diff:${mvicore_version}"
MairwunNx commented 4 years ago

When I tried to compile with that error I got this:

C:\...\android.basics\app\build\tmp\kapt3\stubs\debug\com\example\androidbasics\fragments\FirstFragmentFeature.java:6: error: cannot access Consumer
public final class FirstFragmentFeature extends com.badoo.mvicore.feature.ReducerFeature {
             ^
  class file for io.reactivex.functions.Consumer not found C:\...\android.basics\app\build\tmp\kapt3\stubs\debug\com\example\androidbasics\fragments\FirstFragmentFeature.java:13: error: cannot access ObservableSource
    public static final class State {
                        ^
  class file for io.reactivex.ObservableSource not found C:\...\android.basics\app\build\tmp\kapt3\stubs\debug\com\example\androidbasics\fragments\FirstFragmentFeature.java:56: error: cannot access Disposable
    public static abstract class Wish {
                           ^

and this: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution