Use Realm and Jackson without RxJava dependency.
The Realm docs suggest to add empty Observable and Flowable classes but Realm checks the existence of io.reactivex.Flowable to determine if rx is available and crashes.
Here is the relevant line.
java.lang.NoClassDefFoundError: Failed resolution of: Lio/reactivex/BackpressureStrategy;
at io.realm.rx.RealmObservableFactory.<clinit>(RealmObservableFactory.java:79)
at io.realm.RealmConfiguration$Builder.build(RealmConfiguration.java:806)
at io.realm.Realm.init(Realm.java:247)
...
Realm version(s): 4.1.0
I guess you also need to add the dummy class for io.reactivex.BackpressureStrategy
This does not solve the problem since Realm assumes Rx is present. I get the following exception:
java.lang.NoSuchFieldError: No static field LATEST of type Lio/reactivex/BackpressureStrategy; in class Lio/reactivex/BackpressureStrategy; or its superclasses (declaration of 'io.reactivex.BackpressureStrategy' appears in /data/app/de.mycompany.myapp-2/base.apk:classes3.dex)
at io.realm.rx.RealmObservableFactory.<clinit>(RealmObservableFactory.java:79)
at io.realm.RealmConfiguration$Builder.build(RealmConfiguration.java:806)
at io.realm.Realm.init(Realm.java:247)
Well, we are getting there :smile:
I guess the solution will be
package io.reactivex;
class Observable {
}
and
package io.reactivex;
class Flowable {
}
and
package io.reactivex;
enum BackpressureStrategy {
LATEST;
}
And then it should work.
we should update the doc to reflect these changes
Does not work :
java.lang.IllegalAccessError: Illegal class access: 'io.realm.rx.RealmObservableFactory' attempting to access 'io.reactivex.BackpressureStrategy' (declaration of 'io.realm.rx.RealmObservableFactory' appears in /data/app/eu.mjdev.mediaplayer.debug-1/base.apk)
at io.realm.rx.RealmObservableFactory.
at io.realm.RealmConfiguration$Builder.build(RealmConfiguration.java:805)
at io.realm.Realm.init(Realm.java:248)
at eu.mjdev.mediaplayer.application.Application.onCreate(Application.java:16)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5296)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
Why realm want programmers use RX??? Only cause of observable? They can not write their class?
In most of my apps I use realm only to store json serialized object, as other way does not work.
No HashMap support...
No real ArrayList support...
No simple inner object support...
Only single objects with int, double, string & etc, You call it database?
It is really fast but...
May be this should be better to escape before Rx re-implementation...
Doesn't work
java.lang.IllegalAccessError: Illegal class access: 'io.realm.rx.RealmObservableFactory' attempting to access 'io.reactivex.BackpressureStrategy' (declaration of 'io.realm.rx.RealmObservableFactory' appears in /data/app/io.sendtask-1/base.apk:classes2.dex)
at io.realm.rx.RealmObservableFactory.<clinit>(RealmObservableFactory.java:79)
at io.realm.RealmConfiguration$Builder.build(RealmConfiguration.java:805)
at io.realm.Realm.init(Realm.java:248)
at io.sendtask.application.MainApplication.onCreate(MainApplication.java:41)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4869)
at android.app.ActivityThread.access$1800(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1457)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5582)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@armenm did you try the second half of the answer I provided in https://stackoverflow.com/a/47062181/2413303
Yes, I have created 3 classes in io.reactivex package. jackson-databind section in Realm docs
I use classpath "io.realm:realm-gradle-plugin:4.2.0".
I have also added this to multidex-config.txt
io/reactivex/BackpressureStrategy.class
io/reactivex/Flowable.class
io/reactivex/Observable.class
@armenm
I have never seen that before but i guess you could bring over the whole enum
public enum BackpressureStrategy {
MISSING,
ERROR,
BUFFER,
DROP,
LATEST
}
Most helpful comment
Well, we are getting there :smile:
I guess the solution will be
and
and
And then it should work.