无法解析符号MyObjectBox

问题描述 投票:2回答:1

我正在使用对象框版本1.1.0。使用ObjectBox文档中给出的说明进行安装,但收到此错误。即使我在Objectbox的FAQ部分搜索了这个问题,他们提供的解决方案是删除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
}

app 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'
android database greendao objectbox
1个回答
6
投票

MyObjectBox类是在构建期间生成的,我认为您需要至少有一个带有@Entity注释的模型文件才能生成它。


0
投票

我遇到了同样的问题。就我而言,我没有在@Entity类中声明@PrimaryKey属性。

@Entity
public class Subject {

@PrimaryKey // This line was missing
@SerializedName("id")
@Expose
private int id;

@SerializedName("title")
@Expose
private String title;
}
© www.soinside.com 2019 - 2024. All rights reserved.