领域注释处理器错误未出现

时间:2018-09-09 17:08:09

标签: java android realm

我已经收到有关Realm库的注释处理器无法加载的错误,我丢失了什么吗?我应该在哪里添加它或该怎么办?

这是我得到的错误:

“注释处理器必须立即显式声明。以下与编译类路径有关的依赖关系包含注释处理器。请将它们添加到注释处理器配置中。   -realm-android-0.82.1.jar(io.realm:realm-android:0.82.1)“

请帮助。

App.Gradle

apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.version.crt.myapplication"
    minSdkVersion 22
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'

implementation 'io.realm:realm-android:0.82.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Project.gradle

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'


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

allprojects {
repositories {
    google()
    jcenter()
}
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

请协助!

2 个答案:

答案 0 :(得分:2)

按照realm docs

中的说明进行操作

步骤1:将类路径依赖项添加到项目级别的build.gradle文件中。 (您将其称为“问题计划”)

public dataSource: any;

constructor(props: {}) {
super(props);

this.dataSource = new kendo.data.DataSource({
  type: "odata",
  transport: {
    read: function() {
      return [{ id: 1, name: "Blah" }, { id: 2, name: "Thing" }];
    }.bind(this)
  },
  schema: {
    model: {
      fields: {
        id: { type: "number" },
        name: { type: "string" }
      }
    }
  }
});
}

<ComboBox
   name="test"
   dataSource={this.dataSource}
   placeholder={this.placeholder}
   dataValueField="id"
   dataTextField="name"
/>

第2步:将realm-android插件应用到应用程序级别build.gradle文件的顶部。 (您将其称为有问题的App gradle)

buildscript {
    repositories {
        google() 
        jcenter()
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:5.4.1"
    }
}
...

答案 1 :(得分:1)

在两行下面添加

implementation 'io.realm:realm-android:0.82.1'
annotationProcessor 'io.realm:realm-android:0.82.1'

而不是仅一行

implementation 'io.realm:realm-android:0.82.1'

应该解决了这个问题。