Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse Java: Define final variable based on build configuration
    text
    copied!<p>I want to have a <code>final</code> variable that is <code>true</code> when I run the Debug version of my project, and <code>false</code> when I run the Run version. I understand I can do this with build configurations but have no idea how to set this up in Eclipse. There don't appear to be any tutorials or questions on Stack Exchange regarding defining variables specifically.</p> <p>I'm compiling Java in Eclipse Classic 4.2, creating an Android app using the ADT plugin.</p> <hr> <p>EDIT: Per @Xavi, I set up the following:</p> <pre><code> try { String line = null; java.lang.Process p = Runtime.getRuntime().exec("getprop debugging"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { Log.d("Property:", line); //&lt;-- Parse data here. } input.close(); } catch (IOException e) { e.printStackTrace(); } </code></pre> <p>And in the "Additional Emulator Command Line Options" field of the Target tab of the Debug Configurations window, I've entered:</p> <pre><code>-prop debugging=true </code></pre> <p>Unfortunately it looks like this only works in emulator mode. It doesn't print anything when running on my phone. (It works fine running on an emulator.)</p> <hr> <p>EDIT: Per @Sharks I found some links that seem relevant, but I don't know how to apply them to my situation:</p> <ul> <li><a href="https://stackoverflow.com/questions/5032078/android-use-ant-to-create-build-configurations-that-change-configuration-value">Android - use ant to create build configurations that change configuration values</a></li> <li><a href="http://www.bonobolabs.com/fuck-the-android-build-process/" rel="nofollow noreferrer">http://www.bonobolabs.com/fuck-the-android-build-process/</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload