Android: Managing different server URL for development and release -


i developing android application interacts server via rest apis. need use different url development , release builds. commenting , un-commenting code tedious , error pron.

which best way handle situation? using different build types in gradle file 1 automate process, not sure if right way go.

there possibility of increase in number of build types viz. test, internal-release etc.

if using android studio, use buildconfigfield add custom fields buildconfig class.

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, have 3 build types: standard debug , release, plus custom mezzanine one. each defines server_url field on buildconfig.

then, in java code, refer buildconfig.server_url. field have value based on build type used build particular edition of app.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -