我想在android ant发布和调试版本中附加不同的字符串资源文件.我需要这个有地图api密钥,远程主机等的单独配置
我使用Eclipse进行日常调试构建,然后使用Ant进行发布构建.我有包含Google Maps API密钥的文件的调试版和发行版.我修改了build.xml(我在SDK工具R15上),在构建之前和之后复制相应的文件.我已经改变了-pre-build和release目标,如下所示:
<target name="-pre-build">
<echo message="In pre build-----------------------------------" />
<echo message="build target ${build.target}" />
<if condition="${build.is.packaging.debug}">
<then>
<echo>Copying debug api key************************************</echo>
<copy file="${layout.dir}/googlemapdebug.xml" tofile="${layout.dir}/googlemap.xml" overwrite="true" />
</then>
<else>
<echo>Copying RELEASE api key************************************</echo>
<copy file="${layout.dir}/googlemaprelease.xml" tofile="${layout.dir}/googlemap.xml" overwrite="true" />
</else>
</if>
</target>
<target name="release"
depends="clean, -set-release-mode, -release-obfuscation-check, -package, -release-prompt-for-password, -release-nosign"
............. LINES OMITTED
.............
<!-- Zip aligns the APK -->
<zipalign-helper in.package="${out.unaligned.file}"
out.package="${out.final.file}" />
<echo>Release Package: ${out.final.file}</echo>
<echo>Always copy DEBUG MAPS API file back for Eclipse **********************</echo>
<copy file="${layout.dir}/googlemapdebug.xml" tofile="${layout.dir}/googlemap.xml" overwrite="true" />
</sequential>
</do-only-if-not-library>
<record-build-info />
</target>
Run Code Online (Sandbox Code Playgroud)
我在ant.properties(build.properties发布SDK Tools 14的新名称)文件中定义layout.dir:
projectname=MyProject
workspace.dir=/dev/projects/EclipseIndigo/AndroidWorkTwo
base.dir=${workspace.dir}/${projectname}
layout.dir=${base.dir}/res/layout
Run Code Online (Sandbox Code Playgroud)
您可以根据自己的需要进行调整,假设您没有太多文件可以进行交换.我想你可以为持有strings.xml的目录添加一个属性
| 归档时间: |
|
| 查看次数: |
2545 次 |
| 最近记录: |