Tom Klino
Tom Klino

Reputation: 2514

Get a warning from eclipse when trying to compile a dev app to production?

I'm developing for Android, and this app has a server side.

I have 2 environements on the server side, dev and prod.

dev listens on one port, and production on another.

When I am developing new features, I temporarly set the destination port in my client side code to the dev server to do some testing.

obviously after I'm done testing the new feature myself, I would like to upload the apk to my alpha testers only after I return the client code to use the production port.

except that I forget.

Can I mark somehow some lines of code so that eclipse would compile and run easily when I run for testing, but puts out an error when I try to export a signed app?

NOTE: other ideas that can help with this problem are also welcome valid answers.

Upvotes: 1

Views: 31

Answers (1)

Andy Thomas
Andy Thomas

Reputation: 86459

You can specify a port outside your code.

One way to do this is to define a system property when you launch your application.

For example, you could specify or override the default port with this VM argument:

 -Dcom.tom.myport=8080

Then, in your code, check the value of this with System.getProperty("com.tom.myport").

One option is to make the production behavior the default, and override only in the development environment.

Upvotes: 2

Related Questions