cmelchior / realmfieldnameshelper

Realm extension library used to create more type-safe queries.
Apache License 2.0
173 stars 21 forks source link

Cannot use it in kotlin..Unresolved reference #23

Closed zeroarst closed 6 years ago

zeroarst commented 7 years ago

I can see the field field is generated. It is OK to use with java but not Kotlin. In Kotlin it just shows me "Unresolved reference: XXXFields".

I created a new project and declared a class and use it in Kotlin and can produce this issue.

/build.gradle

buildscript {
    ext.kotlin_version = '1.1.3-2'
    repositories {
        jcenter()
        google()
        maven {
            url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
        }
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:2.2.1"
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://www.jitpack.io" }
    }

app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android'
dependencies {
    annotationProcessor 'dk.ilios:realmfieldnameshelper:1.1.1'
}
teobaranga commented 7 years ago

Have you tried using

dependencies {
    kapt 'dk.ilios:realmfieldnameshelper:1.1.1'
}

instead?

zeroarst commented 7 years ago

I did try. Does not work. Is everything working on your end?

cmelchior commented 6 years ago

I added a section to the README about the order of plugins: https://github.com/cmelchior/realmfieldnameshelper/blob/master/README.md#plugin-order-with-kotlin This is working correctly with Kotlin 1.1.51 and you can see an example project here: https://github.com/cmelchior/realmfieldnameshelper/blob/master/example/build.gradle

zeroarst commented 6 years ago

Thanks. Working after I added apply plugin: 'kotlin-kapt'