I know that I can use debugCompile to only pull in a dependency for the debug build. Is there a good, streamlined way to do the
Using java reflection may be a perferct idea:
private void initStetho() {
if (BuildConfig.DEBUG) {
try {
Class> stethoClazz = Class.forName("com.facebook.stetho.Stetho");
Method method = stethoClazz.getMethod("initializeWithDefaults",Context.class);
method.invoke(null, this);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
then we can debug compile stetho:
debugCompile 'com.facebook.stetho:stetho:1.5.0'