Include Stetho only in the debug build variant

Check the @Tanis answer.

Also you can use something like this:

Add the library only on debug version.

dependencies {
   debugCompile 'com.facebook.stetho:stetho:1.1.1      
 }

In your Application you can do :

public class ExampleApplication extends Application {

  @Override public void onCreate() {
    super.onCreate();
    StethoUtils.install(this);
  }
}

Then you can create different StethoUtils class in the debug/release version.

In src/debug/java/

public class StethoUtils{

   public static void install(Application application){
       Stetho.initialize(
          Stetho.newInitializerBuilder(application)
            .enableDumpapp(Stetho.defaultDumperPluginsProvider(application))
            .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(application))
            .build());

   }
}

In src/release/java/

public class StethoUtils{

   public static void install(Application application){
      // do nothing
   }
}

Leave a Comment