有没有办法将 ant 变量传递给 java 代码(android)? [英] Is there a way to pass ant variables to java code (android)?
问题描述
我喜欢在我的应用程序中包含一些构建变量.例如内部版本号.我可以将一些变量从 ant 构建脚本传递给我的 Android 应用程序并在 java 中使用该变量吗?
I like to include some build variables in my application. For example a buildnumber. Can I pass some variables from a ant build script to my Android application and use that variable in java?
有人有链接或例子吗?
推荐答案
只需将内部版本号填充到一个字符串 xml 文件中并正常读取即可.您可以使用 替换任务 来做到这一点..
Just populate the build number into a string xml file and read it as normal. You can use the replace task to do that..
不要使用属性文件,因为没有 Android 原生方式来读取它.本机方式是 xml 文件中的字符串值.并且最好将其替换为静态字符串xml文件而不是java源代码.
Dont use a properties file since there is not Android native way to read it. The native way are string values in the xml files. And it is better to replace it into a static strings xml file rather than java source code too.
这篇关于有没有办法将 ant 变量传递给 java 代码(android)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!