Say I have flavour free / paid.
I want to call a method checkSubscription()
for a paid feature. The classes referred inside that method will only be available for paid flavour, because I have put them in a different module, that compiles only for flavour paid.
Is above thing possible?, because when I'll run free flavour app, this should not give classNotFoundException
. Please guide me.
Edit
Yes I am aware that I can check my flavour programmatically in Java like
if (BuildConfig.BUILD_VARIANT.equals("Your flavor name")){
//do something
}
or by defining a buildConfigField
.
I explain better
- My class
Example.java
is in module PaidLibrary, and PaidLibrary is only compiled for the paid flavour. - Now I have a class
ActivityExample.java
, in which I have importedExample.class
. - I check current flavour before using this
Example.java
, but will this createclassNotFoundException
becauseActivityExample.java
contains import and use ofExample.java
. - So this is my question that how to code for classes which are available for paid flavour?
try using reflection: