Here is how it is done:
Do NOT set proguard.config=proguard.cfg in your project.properties file.
in your build.properties file set
proguarded=on # or whatever variable you chose
Define these Macros if you are building Android so that debugging is always off:
<macrodef name="set-app-debuggable">
<sequential>
<echo>Updating AndroidManifest.xml with debuggable set to true</echo>
<replaceregexp file="./AndroidManifest.xml"
match='android:debuggable="(.*)"'
replace='android:debuggable="true"'
byline="false">
</replaceregexp>
</sequential>
</macrodef>
<macrodef name="set-app-not-debuggable">
<sequential>
<echo>Updating AndroidManifest.xml with debuggable set to false</echo>
<replaceregexp file="./AndroidManifest.xml"
match='android:debuggable="(.*)"'
replace='android:debuggable="false"'
byline="false">
</replaceregexp>
</sequential>
</macrodef>
Then set these conditions or similar to these depending on if you want to preserve debugging outside proguard builds:
<target name="-set-mode-check">
<echo> set mode checking properties ... </echo>
<echo> Proguard Property value is '${proguard.config}' </echo>
<echo> Proguard Property value is '${proguarded}' </echo>
<condition property="proguard.config" value="proguard.cfg">
<isset property="proguarded"/>
</condition>
<echo> Proguard Property value after condition set is '${proguard.config}' </echo>
<if condition="${proguarded}">
<then>
<echo>**** This build is proguarded so setting debuggable off ****</echo>
<set-app-not-debuggable />
</then>
<else>
<echo>**** This build is not proguarded so setting debuggable on ****</echo>
<set-app-debuggable />
</else>
</if>
</target>
No need to set proguard.config in the project.properties file at all.