2014-10-22 31 views
2

我一直試圖熟悉GreenDao Android ORM庫。我一直在跟隨綠色機器人的例子,但已經陷入困境。每當我得到我的一個daos的實例,UserDao,我沒有任何種類的與dao對象關聯的queryBuilder()方法。GreenDao:queryBuilder不是實體dao上的方法

import package.DaoMaster; 
import package.DaoMaster.DevOpenHelper; 
import package.DaoSession; 
import package.UserDao; 

public class DatabaseHelper { 

    private SQLiteDatabase db; 
    private DaoMaster daoMaster; 
    private DaoSession daoSession; 

    public DatabaseHelper(Context context) { 
     DevOpenHelper helper = new DaoMaster.DevOpenHelper(context, "db", null); 

     this.db = helper.getWritableDatabase(); 
     this.daoMaster = new DaoMaster(db); 
     this.daoSession = this.daoMaster.newSession(); 

     // attempting to retrieve the queryBuilder instance from a user dao.... 
     // however, no queryBuilder method exists 
     this.daoSession.getUserDao().queryBuilder(); 
    } 
} 

我在想什麼?我正在使用greendao-generator神器,版本號爲1.3.1

回答

0

終於明白了這一點。首先,我使用Android Studio 0.8.9,它使用Gradle 2.1

在項目的app文件夾中的build.gradle文件中,我將compile('de.greenrobot:greendao:1.3.7')添加到其dependencies部分。它看起來是這樣的:

dependencies { 
    // ... 
    compile 'de.greenrobot:greendao:1.3.7' 
    // ... 
} 

從那時起,該queryBuilder方法是適用於所有我daos