Add greenDAO to your Android project
masterTo use greenDAO, you must add both the Gradle plugin to your root build file and the library dependency to your app module. The plugin is responsible for generating essential classes like DaoMaster, DaoSession, and individual DAOs during the build process.
- Root
build.gradle: AddmavenCentral()to repositories and include thegreendao-gradle-pluginin thedependenciesblock. - App
build.gradle: Apply theorg.greenrobot.greendaoplugin and add thegreendaoimplementation dependency.
// In your root build.gradle file:
buildscript {
repositories {
jcenter()
mavenCentral() // add repository
}
dependencies {
classpath 'com.android.tools.build:gradle:<agp-version>'
classpath 'org.greenrobot:greendao-gradle-plugin:3.3.1' // add plugin
}
}
// In your app modules app/build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao' // apply plugin
dependencies {
implementation 'org.greenrobot:greendao:3.3.0' // add library
}