I am trying to implement robobinding with product flavors but the custom code classes under the flavor's source directory never get executed.
Has anyone tried anything similar to this use-case? i.e. used some kind of element binders and then implemented product flavors?
On a certain demo project the structure I have:
-app/src/main/java/demo.app.pkg/MainActivity.java
-app/src/free/java/demo.app.pkg.free/MainActivity.java
build.gradle
:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
free {
applicationId "demo.app.pkg.free"
}
paid {
applicationId "demo.app.pkg.paid"
}
}
and when the MainActivity.java
class is modified present under free
flavor it does get packaged when the free
flavor's debug/release is built. and is executed as well containing the custom code.
(On a side Note: some say that in-order to implement product flavors which has different versions of a single class one needs to have a src folder for main
containing common code (but not the classes having same name present in the flavor's src folders) and other 2 src folders which have the class(es) having same name etc. which would essentially segregate the two flavors.
This wasn't the case with the sample project I tried above^ it worked flawlessly; even when I had the same named class under main
src folder.)
Now, the issue lies when I try to implement similar kind of product flavors (as seen above) in a project already having robobinding implemented. Structure goes like:
-app/src/main/java/demo.app.pkg/MainActivity.java
-app/src/main/java/demo.app.pkg/MainActivityPresentationalModel.java (class to be replaced by class present under 'free' flavor)
-app/src/main/java/demo.app.pkg/Pojo.java
-app/src/free/java/demo.app.pkg.free/MainActivityPresentationalModel.java
This thing doesn't work. Only the class MainActivityPresentationalModel.java
under main
gets executed.
Now, if anyone has used view binders
especially robobinding or SDK's binders
(still under beta) they must be aware of that we get access to a presentational model which is essentially logic where we have setter/getters to get/put values so that they get updated on the UI at runtime and hence my motive to have this class in a product flavor.
Any help is much appreciated.
Reference:
For the first sample project kindly have a look at 'Build-It-Bigger' project on gitHub.