简体   繁体   中英

How to use Realm database with Java 8 features

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
    }

Unfortunately Jack compiler and Realm can't play together right now. Please follow that topic . That one is also useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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