Search code examples
androidandroid-productflavorsstetho

Android build flavors with different Applications


I'm trying to separate debug and release functionality in my app. For instance I'm using Stetho and Mortar libraries. They both require overridden Application class. But I would like Stetho to be accessible only in debug build. There are at least two approaches:

Have MyApplication class in release and debug flavors with different code. But in this case code which should be user in release build is duplicated.

MyDebugApplication extends MyApplication and contains only debug related stuff. In this case two Manifest files are required and merged some how.

So I'm wondering which approach is more efficient ?


Solution

  • You totally should use two base MyBaseApplication classes in the release and debug flavor and then extend the MyApplication class on your main scope.

    This way the logic woun't be duplicated, and you'll have two different behaviours on debug and release.