首先就是配置greendao數據哭的環境
1.在主項目中的build.gradle 經行配置環境 :(自己這樣用的僅供參考)
apply plugin: 'org.greenrobot.greendao'
compile 'org.greenrobot:greendao:3.2.0' compile 'com.github.yuweiguocn:GreenDaoUpgradeHelper:v2.0.1'2.在工程裏的build.gradle 裏配置
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
環境配置好後,如果你要自動生成文件和包,需要在主項目中的build.gradle配置如下:
greendao{ schemaVersion 7 //設置DaoMaster、DaoSession、Dao包名,也就是要放置這些類的包的全路徑。 daoPackage 'greendao' targetGenDir 'src/main/java' }
鏈接爲升級的utils(僅供參考:添加String類型不會報錯,但是添加int byte類型的都會出現NOT NULL約束不通過)
目前還在嘗試如何修改這問題
這篇說解決了,可以嘗試下解決數據庫升級添加任意字段