我怎样才能在Android的蚂蚁释放连接不同的字符串资源文件和调试版本?字符串、蚂蚁、不同、版本

2023-09-04 13:07:10 作者:生活不相信眼泪

我想在Android的蚂蚁释放和调试版本附上不同的字符串资源文件。我需要这对地图API密钥单独的配置,远程主机等

I want to attach different string resources files during android ant release and debug builds. I need this to have separate configuration for map api key, remote host etc

推荐答案

我使用Eclipse进行日常调试版本,则Ant的发布版本。我有一个文件持有谷歌地图API密钥的调试和发行版本。我已经修改了的build.xml(我在SDK工具R15)构建之前和之后做了相应的文件的一些复制。我已经改变了 - pre-构建和发布指标,像这样:

I use Eclipse for day to day debug builds, then Ant for release builds. I have debug and release versions of the file holding the Google Maps API key. I've modified the build.xml (I'm on SDK tools R15) to do some copying of the appropriate file before the build and afterwards. I've changed the -pre-build and release targets like so:

    <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>

我在ant.properties定义layout.dir(新名称build.properties发布SDK工具14)文件:

I define layout.dir in the ant.properties (new name for build.properties post SDK Tools 14) file:

projectname=MyProject
workspace.dir=/dev/projects/EclipseIndigo/AndroidWorkTwo
base.dir=${workspace.dir}/${projectname}
layout.dir=${base.dir}/res/layout

您能够适应这种满足您的需求,假设你没有太多的文件交换和缩小。我想你可以在目录中添加一个属性,为你的strings.xml

You could adapt this to suit your needs, assuming you don't have too many files to swap in and out. I guess you could add a property for the directory holding your strings.xml