Stetho is an Android library that enables extended debugging options.
What’s wrong with this piece of code?
It executes even in release builds
It might not, but chances are it does. You are going to place this code in
app/src/main/java/your_package/MyApplication.java, right? If so, Stetho will run in every build type, because this path corresponds to the
main source set. This could lead to unwanted device resource consumption in production.
A. Change the source set
debug folder under
app/src and move your
MyApplication class there. Thus you make it be used in debug builds only. Stetho initialization code is not going to run in release builds any more.
B. Do runtime checks
Another approach is to check an automatically generated
BuildConfig class property at run time: