I have an ant script that does what it needs to do, but I need to set a few property values based on whether I'm running release or debug. How do I do this?
If it makes a difference, my ant script runs some custom utility tasks before performing android build.
To answer my own question:
The properties to look for are "build.mode.release" and "build.mode.debug", however there IS a caveat ... if your manifest has debuggable="true", the system REVERTS to debug mode with a slight 'short-coming' (IMO)
- build.mode.release is NOT set,
- build.mode.debug is ALSO not set
- Debug signing is disabled (you have to provide a keystore, alias, and password)
Note: This applies only to Android builds
final soultion for ant debug and jni module:
1. in custom_rules.xml, assign debug mode to 'BUILDMODE'
ifeq ($(BUILDMODE), true)
LOCAL_CFLAGS=-DDEBUG
endif
As an update to Joe's answer, it looks like, at least with Android Tools revision 22.3, the property build.mode.debug no longer exists, but you can use build.is.packaging.debug to differentiate between debug and release
The reason for the "caveat" is actually documented in the Android
main_rules.xml
project ($ANDROID_SDK_ROOT/tools/ant/main_rules.xml
):So what you want to check for is
build.mode.debug
(executed viaant debug
),build.mode.release
(when@debuggable=false
and executed withant release
), and finally to meet your caveat:build.packaging.debug
(when@debuggable=true
and executed withant release
)Here's an example that would work pre-compile automatically:
ant -D<prop-name>=<value>
will set property in ant