我正在使用对象框1.1.0。安装在对象盒文档中给出的说明,但会遇到此错误。甚至我在Objectbox的常见问题解答部分中搜索了此问题,它们提供的解决方案是删除Android-Apt。但是在Gradle文件中,没有使用Android-Apt。因此,如何克服这个问题,请帮助我。Bellow是我的根级Gradle文件
buildscript {
ext {
_buildToolsVersion = '26.0.1'
_compileSdkVersion = 26
objectboxVersion = '1.1.0'
}
repositories {
jcenter()
mavenCentral()
maven { url "http://objectbox.net/beta-repo/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.1.0'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
}
}allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
maven { url "http://objectbox.net/beta-repo/"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序Gradle文件在
下方apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.kingof.android"
minSdkVersion 16
targetSdkVersion 25
versionCode 3
versionName "1.001"
multiDexEnabled = true
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
lintOptions {
disable 'ValidFragment'
}
}
repositories{
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.patrickpissurno:ripple-effect:1.3.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.snatik:storage:2.1.0'
compile 'jp.wasabeef:glide-transformations:2.0.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile "io.objectbox:objectbox-android:$objectboxVersion"
}apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.objectbox'
myObjectBox class是在构建过程中生成的,我认为您需要至少将一个模型文件带有 @entity andotation的注释被生成。
我面临同一问题。就我而言,我没有在 @entity类中声明@primarykey属性。
@Entity
public class Subject {
@PrimaryKey // This line was missing
@SerializedName("id")
@Expose
private int id;
@SerializedName("title")
@Expose
private String title;
}
我有相同的错误,但这是出于截然不同的原因,我在较高的级别包中有一个实体类,因此将任何类放在 @实体标签在同一软件包中或低于对象盒类解决我的问题