gpt4 book ai didi

android - Realm NoClassDefFoundError : rx. 可观察

转载 作者:太空宇宙 更新时间:2023-11-03 11:36:30 25 4
gpt4 key购买 nike

我遇到了 Realm 文档中指出的问题:

Jackson Databind

Jackson Databind is a library for binding JSON data to Java classes.

Jackson uses reflection to perform the data binding. This conflicts with Realm’s support for RxJava, as RxJava might not be available to the class loader. This can result in an exception that looks like this:

Copy to clipboardjava.lang.NoClassDefFoundError: rx.Observable
at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
...

这是建议的修复:

This can be fixed by either adding RxJava to your project or create two empty dummy files that looks like the following.

Copy to clipboard// File 1
package io.reactivex;

public class Flowable {
}


// File 2
package io.reactivex;

public class Observable {
}

This issue has also been reported to the Jackson project here.

问题:我应该在哪里创建文件,这样它们就没有我应用程序的包名称? (例如:com.myApp.myPackage)

旁注:我是从 SimpleXml 遇到这个问题的,而不是 Jackson(也许 simplexml 使用 jackson?)。我看到了 2 个错误:

  1. Realm NoClassDefFoundError:rx.Observable Realm
  2. NoClassDefFoundError: io.reactivex.Observable

最佳答案

您正在使用早于 v4.0.0 的 Realm,因此您需要创建包 rx,以及名为 Observable 的虚拟类。但是你只需要在 src/main/java/rx 中创建它。

package rx;

public class Observable {
}

对于 Realm 4.0.0+,你需要在 src/main/java/io/reactivex 中。

package io.reactivex;

public class Observable {
}

package io.reactivex;

public class Flowable {
}

package io.reactivex;

public enum BackpressureStrategy {
MISSING,
ERROR,
BUFFER,
DROP,
LATEST
}

关于android - Realm NoClassDefFoundError : rx. 可观察,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47061821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com