參考greendao的官方文檔這裡寫連結内容
1.在項目project的root目錄下build.gradle檔案中配置如下:
buildscript {
repositories {
jcenter()
mavenCentral() // 添加倉庫
}
dependencies {
classpath ‘com.android.tools.build:gradle:2.2.3’
classpath ‘org.greenrobot:greendao-gradle-plugin:3.2.1’// 添加 plugin
}
}
2.在module的build.gradle檔案中配置如下:
apply plugin: ‘com.android.application’
apply plugin: ‘org.greenrobot.greendao’// 應用plugin
android {
/針對greenDao的一些配置/
greendao {
schemaVersion 1 //資料庫版本号
daoPackage ‘com.jiajia.greendao.dao’//生成的工具類的包名
targetGenDir ‘src/main/java’//生成的工具所在路徑
}
}
dependencies {
compile ‘org.greenrobot:greendao:3.2.0’//添加依賴
}
3.編譯一下項目