我正在尝试将领域集成到 Java/Kotlin 项目中,但即使是 .java 文件,kapt 也不会生成 RealmProxy 类
我因此更新了领域,但仍然无法正常工作
Gradle 应用程序文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
kapt {
generateStubs = true
}
project.ext {
daggerVersion = '2.2'
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
kapt "com.android.databinding:compiler:2.3.3"
annotationProcessor group: 'com.google.dagger', name: 'dagger-compiler', version: "${daggerVersion}"
compile group: 'com.google.dagger', name: 'dagger', version: "${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
provided group: 'org.glassfish', name: 'javax.annotation', version: '10.0-b28'
testAnnotationProcessor group: 'com.google.dagger', name: 'dagger-compiler', version: "${daggerVersion}"
testCompile group: 'com.google.dagger', name: 'dagger', version: "${daggerVersion}"
androidTestAnnotationProcessor group: 'com.google.dagger', name: 'dagger-compiler', version: "${daggerVersion}"
androidTestCompile group: 'com.google.dagger', name: 'dagger', version: "${daggerVersion}"
}
...
项目文件:
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:3.5.0"
}
}
...
Java模型文件:
@RealmClass
public class NotificationEventsModel extends RealmObject {
@PrimaryKey
private long classPK;
@SerializedName("userNotificationEventsCount")
private int eventsCount;
}
Kotlin 模型文件:
@RealmClass open class PageModel(
open var classPK: Long = 0,
open var content: String? = null,
@PrimaryKey
open var id: Long = 0,
) : RealmObject() {
}