0

For my Android app I use Android Studio. My application made some request to my server. I have 2 servers: development (for tests) and production (for releases).

And in my code I have variable, which save server url like:

private static final String SERVER_URL = "http://192.XXX.XXX.XXX:XXXXX"; // production
private static final String SERVER_URL = "http://192.YYY.YYY.YYY:YYYYY"; // development

And during tests - I just commented production variable, but for releases - I removed development variable.

Sometimes I can forgot to remove development variable for release version (and this can be a huge problem).

My question is: may be I can add some attribute to development variable (or something other), by which Android Studio not be able to prepare APK file?

jimpanzer
  • 3,470
  • 4
  • 44
  • 84
  • Typically you would have the build system inject the test or public URL into a test or release build accordingly - so you don't have to remember to change it. – Chris Stratton Feb 25 '15 at 07:07
  • Thanks for your comment. Can you give me more information about "best practice". Some links also will be helpfull too. Note: I use gradle build tool. – jimpanzer Feb 25 '15 at 07:12
  • 1
    See http://stackoverflow.com/questions/27875748/android-studio-switching-a-url-depending-on-buildtype-used-for-testing-in-deb – Scott Barta Feb 25 '15 at 17:23
  • @ScottBarta, thanks. This is almost the same what I want. I think the ideal solution will be Android Studio plugin, which will provide 2 options: 1) Generate Signed Apk with Test data and 2) Generate Signed Apk with Production data. And it will use 2 different xml with config. – jimpanzer Feb 26 '15 at 13:49

0 Answers0