Does anyone know if it’s possible to get variables from the AndroidManifest.xml for ant use?
Specifically, I’m trying to get versionCode,versionName, and packageName out somehow.
Thanks in advance.
Conclusion
It seems that this is too troublesome to do, and since this problem is easily solved with Maven I’ve given up on the possibility of a quick solution for now.
Maybe there is an android dedicated solution, which i dont know, but apart from that you can treat android manifest file as any other xml file -> so all you need is an ant task for parsing xml file and retrieving values from it.
as writing custom ant task in java is not a rocket science – there allready is something you could try to use.
see: How to parse a xml by ANT
so in your case it would be sth like (with use of http://www.oopsconsultancy.com/software/xmltask/):
EDIT:
If you think about parsing this in your android project’s build.xml then you have xpath task “out of the box”. Any automatically generated build file for android project imports the global sdk’s build file
<import file="${sdk.dir}/tools/ant/build.xml" />, in which you have:And example usage some lines later: