WebMajstr WebMajstr - 1 year ago 69
Android Question

greenDAO for only one flavor of the app

I use greenDAO just in one flavor of the app, and I would like to avoid adding the dependency to the flavor that does not use it so that application is not bloated.

The problem that I'm having is that

apply plugin: 'org.greenrobot.greendao'
is applied for both flavors which causes build script to fail for the flavor that does not use greenDAO.

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'

android {
...
productFlavors {
lite {
...
}
pro {
...
}
}
}

greendao {
schemaVersion 1
}

dependencies {
proCompile 'org.greenrobot:greendao:3.2.0'
}


How could I solve this, any idea?

EDIT:

To be more specific, it looks like greenDAO builds all classes marked with @Entity even if they are in different flavor and puts them into folder
\build\generated\source\greendao\com\test\app\database
This causes build errors as classes can not be found (which of course could not be, as they are defined in different flavor).

Answer Source

Currently greenDao does not support this. The bug regarding this is open on their issue tracker on GitHub and let's hope it will be addressed soon.

Link to the issue: https://github.com/greenrobot/greenDAO/issues/587

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download