0

Where should I declare a class that only must be compiled for the debug variant of an app in Android Studio?

What I want to make is to save some faked responses from a web service, stripping it from the release version to ensure never ship that code:

 public static DebugFakeResponses{
     public static final String RESPONSE_SERVER_IN_MAINTENTANTE
                               ="{\"error\":\"In Maintentance\"}";
 }

Thanks

Addev
  • 31,819
  • 51
  • 183
  • 302

1 Answers1

0

I don't think, you can exclude something from compiling in debug mode without using a build system. But you could simply check, if you're in debug mode and execute the code only in this case:

if (BuildConfig.DEBUG) {
  // do something for a debug build
}

Source

Community
  • 1
  • 1
Darek Kay
  • 15,827
  • 7
  • 64
  • 61