2017-09-12 14 views
1

内のゲッターとコンストラクタを生成しません。ObjectBoxは</p> <p><a href="http://objectbox.io/documentation/introduction/" rel="nofollow noreferrer">http://objectbox.io/documentation/introduction/</a>は、私は、Android Studioの2.3.3</p> <p>私のGradleファイルで新しいプロジェクトを作成し、このページを使用して、私はOBを始めるためにしようとしている事業体

ROOT:

// 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 
} 

APP:

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() 

答えて

2

ObjectBoxはソースファイルにコードを生成しません(greenDAOとは異なります)。だから、2つのオプションがあります。また、ここではこれについての段落を追加した

  1. private
  2. 標準ゲッター(あなたのIDEを簡単に生成することができます)
+0

PSを.:提供を除去することにより、フィールドパッケージはプライベートください: http://objectbox.io/documentation/entity-annotations/ –

+0

私のプロジェクトを動作させるために、私はフィールドパッケージをprivateに設定し、すべてのgetterと2つのコンストラクタを生成しました。idとnon-paramコンストラクタ以外のparamsで生成しました。どのように使用する予定ですか?公式の文書と一致しないので私は尋ねる。 – Roman

関連する問題

 関連する問題