Problem Statement: I want to use a library only on development environment but not on release (app store release). And I don't want that library to get built in release apk also.
My appraoch:
So, I have an environment setup like this:
Development -
- Debug
- Release
Store -
- Debug
- Release -> This goes to play store
In gradle I have added -
debugCompile 'com.some.library'
Which loads this library for Development - Debug and Store - Debug
And then I have created two Application classes,
- ApplicationWithoutDebugLibrary extends MultiDexApplication - Application class which doesn't initializes the library.
- ApplicationWithDebugLibrary extends ApplicationWithoutDebugLibrary - Application class Which initialises the library
And I have defined in gradle to load different Application file for different flavour.
productFlavors {
Development {
applicationId "xyzzzz"
manifestPlaceholders = [application:"com.xyz.ApplicationWithDebugLibrary"]
}
store {
applicationId "11111"
manifestPlaceholders = [application:"com.xyz.ApplicationWithoutDebugLibrary"]
}
}
And in manifest I have written this:
<application
android:name="${application}"...
So, for Debug it is working fine but when I am building Store-Release/ Development-Release apk it is not able to compile ApplicationWithDebugLibrary.java, as I am using the library, which is not compiled in gradle file for release flavour.
So, is there any way in which we can avoid loading this class for Store release flavour, or any alternate solution in which I can load that library only in Development environment.