java - Different parameters for dev and production environments using Gradle -
java - Different parameters for dev and production environments using Gradle -
in android java project gradle build configured using android studio ide, want have variables alter according build environment.
for instance, if there's public static final boolean use_local_backend = false;
in utils.java, production should have false
value , development may want have true
utilize local server debugging.
i'm not expert gradle, i'd appreciate detailed guide on how configure project have 2 different properties
files each environment, each has same keys different values.
the simplest solution, far, move use_local_backend
buildconfig
:
android { // other stuff here buildtypes { debug { buildconfigfield "string", "server_url", '"http://test.this-is-so-fake.com"' } release { buildconfigfield "string", "server_url", '"http://prod.this-is-so-fake.com"' } mezzanine.initwith(buildtypes.release) mezzanine { buildconfigfield "string", "server_url", '"http://stage.this-is-so-fake.com"' } } }
here, defining server_url
string
field on buildconfig
3 build types (debug
, release
, , custom mezzanine
one). same thing boolean
use_local_backend
. refer in java code buildconfig.use_local_backend
.
java android gradle android-studio android-gradle
Comments
Post a Comment