Best Way to Include Debug Code?

Instead of using your own flag, you can use the flag set automatically by ADT, like this: final static int appFlags = context.getApplicationInfo().flags; final static boolean isDebug = (appFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 The FLAG_DEBUGGABLE bit is automatically set to true or false, depending on the “debuggable” attribute of the application (set in AndroidManifest.xml). The … Read more

Gradle : how to use BuildConfig in an android-library with a flag that gets set in an app

As a workaround, you can use this method, which uses reflection to get the field value from the app (not the library): /** * Gets a field from the project’s BuildConfig. This is useful when, for example, flavors * are used at the project level to set custom fields. * @param context Used to find … Read more

BuildConfig not getting created correctly (Gradle Android)

Please, be sure that you are building “dev” or “prod” variant. There is no BuildConfig definition in default “debug” and “release” variant. In Android Studio, you can select current variant in bottom left corner: To simplify your build.gradle file, you can define: buildTypes { debug { buildConfigField “String”, “URL_SEARCH”, “\”https://dev-search.example.com\”” // etc. } release { … Read more