如何使用Java 8功能的Realm数据库 [英] How to use Realm database with Java 8 features

查看:196
本文介绍了如何使用Java 8功能的Realm数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我修改了我的gradle文件以包含杰克工具链,以便我可以使用Java 8语言功能。我还修改了Gradle文件以安装领域插件。当我同步项目gradle文件时,我收到以下错误:错误:无法在任务':app:compileDebugJavaWithJack'上找到属性'选项'。这两个修改本身就可以正常工作,但由于某种原因,我不能同时拥有两个修改。



我非常感谢这方面的帮助。

解决方案

目前无法在Realm中使用Jack编译器,因为Jack不支持字节码操作(Javassist / Transform API)。



为了使用lambda表达式,您现在更容易使用Retrolambda。



<$ p $
// ...
依赖项{
classpathio.realm:realm-gradle-plugin:1.1.0
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}

  apply plugin:'me.tatarka.retrolambda'
apply plugin:'realm-android'

android {
...

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetComp适用性JavaVersion.VERSION_1_8
}


I am new to using Realm database for Android.

I modified my gradle files to include the Jack toolchain so that I could use Java 8 language features. I also modified the gradle files to install the Realm plugin. When I synced the project gradle files, I received the following error: Error:Could not find property 'options' on task ':app:compileDebugJavaWithJack'. The two modifications work fine on their own, but for some reason I cannot have both at the same time.

I would very much appreciate help on this matter.

解决方案

It is not possible to use Jack compiler with Realm at the moment, because Jack does not support bytecode manipulation (Javassist / Transform API).

In order to use lambdas, it's easier for you to use Retrolambda instead for the time being.

buildscript {
     //...
     dependencies {
        classpath "io.realm:realm-gradle-plugin:1.1.0"
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
    }
}

And

apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'

android {
    ...

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

这篇关于如何使用Java 8功能的Realm数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆