领域注释处理器错误未出现 [英] Realm annotation processor error not picking up
问题描述
我已经收到有关Realm库的注释处理器无法加载的错误,我丢失了什么吗?我应该在哪里添加它或该怎么办?
I have been getting the error about the annotation processor for the Realm library fails to load, am I missing something? Where do I add it in or what should I do?
这是我得到的错误:
注释处理器现在必须显式声明.发现以下与编译类路径有关的依赖关系包含注释处理器.请将它们添加到注解处理器配置中. -realm-android-0.82.1.jar(io.realm:realm-android:0.82.1)"
"Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - realm-android-0.82.1.jar (io.realm:realm-android:0.82.1)"
请帮助.
App.Gradle
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
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
}
请协助!
推荐答案
按照领域文档
步骤1:将类路径依赖项添加到项目级别的build.gradle文件中. (您将其称为问题计划")
Step 1: Add the class path dependency to the project level build.gradle file. (Which you refer to as Project gradle in question)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:5.4.1"
}
}
...
第2步:将realm-android插件应用到应用程序级别build.gradle文件的顶部. (您将其称为有问题的App gradle)
Step 2: Apply the realm-android plugin to the top of the application level build.gradle file. (Which you refer to as App gradle in question)
apply plugin: 'realm-android'
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'
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'
}
这篇关于领域注释处理器错误未出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!