简体   繁体   English

不支持java.lang.Double领域对象

[英]java.lang.Double is not supported Realm Object

Basically I had a working app using realm that would work fine until I tried to import firebase into it and things changed. 基本上,我有一个使用领域的工作应用程序,在尝试将Firebase导入其中并且情况发生变化之前,它可以正常工作。 It wouldnt see realm anymore and after I fixed relam import, now it says 在我修复了relam导入之后,它不再会看到领域,现在它说

Error:(10, 8) error: Type java.lang.Double of field price is not supported

this is how my class looks like: 这是我的班级样子:

public class RealmTruck extends RealmObject {
    @PrimaryKey
    private String name;

    private String location;
    private Double price;
    private Integer registrationYear;
    private String version;

I mention again that this was working. 我再次提到这是行得通的。 And if I switch realm from 0.82.1 version to 0.83.0.+ I get this: 如果我将领域从0.82.1版本切换到0.83.0。+,我会得到:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not find any version that matches io.realm:realm-android:0.83.0.+.
     Versions that do not match:
         0.87.5
         0.87.4
         0.87.3
         0.87.2
         0.87.1
         + 31 more
     Required by:
         LoginTest:app:unspecified

What is going on? 到底是怎么回事? I really didnt change anything to it. 我真的没有改变任何东西。 I tried recompiling, reimporting, clearing cached indexes, nothing works. 我尝试重新编译,重新导入,清除缓存的索引,但没有任何效果。

If I try grandle sync now, I get this: 如果我现在尝试同步同步,则会得到以下信息:

Error:(33, 13) Failed to resolve: io.realm:realm-android:0.83.0.+
<a href="openFile:D:/Projects2016/Android/LoginTest/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

I'm using Android Studio, the latest version I believe 我使用的是Android Studio,我认为是最新版本

That's because Realm doesn't support Double , Integer , etc. classes before 0.83.0. 这是因为Realm在0.83.0之前不支持DoubleInteger等类。

0.83.0 and above introduced NULL support , which allows nullable primitives. 0.83.0及更高版本引入了NULL support ,它允许可为空的基元。

Although it's recommended that you upgrade at least to 0.87.5 or 0.88.3 without changing too much existing logic in your Realm code . 尽管建议您至少升级到0.87.5或0.88.3,而不要在Realm代码中更改太多现有逻辑

If this is a new project, and Realm is newly introduced, then you should go for either 1.2.0 , or the latest version available. 如果这是一个新项目,并且新引入了Realm,那么您应该选择1.2.0或可用的最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM