我正在尝试通过使用此页面http://objectbox.io/documentation/introduction/开始使用 OB
我在 Android Studio 2.3.3 中创建了一个新项目
我的 Gradle 文件:
根:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "http://objectbox.net/beta-repo/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "io.objectbox:objectbox-gradle-plugin:1.0.1"
}
}
allprojects {
repositories {
jcenter()
maven { url "http://objectbox.net/beta-repo/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序:
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.obox"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile "io.objectbox:objectbox-android:1.0.1"
annotationProcessor "io.objectbox:objectbox-processor:1.0.1"
}
在APP -gradle 文件中有或没有 2 行较低的行时,它都不起作用。
我的实体类:
package com.example.obox;
import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;
@Entity
public class MyModel {
@Id
private long id;
private String content;
}
没有添加生成的代码。所以我在尝试制作项目时遇到错误。
.../MyModelCursor.java
Error:(45, 32) error: cannot find symbol method getContent()
Error:(48, 57) error: cannot find symbol method getId()
Error:(56, 15) error: cannot find symbol method setId(long)
.../MyModel_.java
Error:(91, 26) error: cannot find symbol method getId()