1

I use Stetho for my Android app. I wish to remove this whenever I create a Release build or a Prod Flavour... Either is fine.

How do I achieve this?

Subby
  • 5,370
  • 15
  • 70
  • 125

1 Answers1

0

You can specify that a library should only be used for specific builds by using debugImplementation instead of implementation in your build.gradle file. In fact, you can specify any combination of build type and/or flavor. For more details, see Specify Dependencies in the Android documentation.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • But then, I will get: `error: package com.facebook.stetho does not exist` – Subby Aug 05 '18 at 17:41
  • @Subby Please create a [mcve] that produces that error. – Code-Apprentice Aug 05 '18 at 17:42
  • 1
    What code exactly? The problem here is that if I state in my gradle file `debugImplementation`, the library successfully is removed on a release build. Good. The problem though is that the code that uses that library within the app will show as an error since gradle removed the library. – Subby Aug 05 '18 at 17:43
  • So it throws an exception on this: `import com.facebook.stetho.Stetho;` – Subby Aug 05 '18 at 17:44
  • @Subby Start a new project and write just enough code to illustrate the problem. Be sure to read the link I gave for tips. Also read https://stackoverflow.com/questions/30172308/include-stetho-only-in-the-debug-build-variant for more suggestions about solving your specific problem. – Code-Apprentice Aug 05 '18 at 17:44