在Android中的Ant构建期间更改应用程序标签

时间:2014-02-04 14:11:01

标签: java android ant command-line

我正在尝试通过命令行在Ant构建期间重命名我的Android应用程序。我想这样做,因为我想为不同的环境(测试,预生活,登台等)创建相同应用程序的不同版本。我能够更改软件包名称,versionName,versionCode,它允许我在单个设备上安装所有变种。现在我需要更改应用程序的名称,该名称来自

android.label
AndroidManifest中的

我在custom_rules.xml中尝试了以下操作,但它无法正常工作

<target
    name="-pre-build"
    depends="-custom-manifest-version" >
</target>


<!-- change the version name and label for the application -->

<target name="-custom-manifest-version" >


    <replaceregexp
        byline="true"
        file="AndroidManifest.xml"
        match="android:versionName=&quot;/*.*&quot;"
        replace="android:versionName=&quot;${app.newversionname}&quot;" >
    </replaceregexp>

    <replaceregexp
        byline="true"
        file="AndroidManifest.xml"
        match="android:label=&quot;/*.*&quot;"
        replace="android:label=&quot;${app.newappname}&quot;" >
    </replaceregexp>
</target>

但这没有帮助,应用程序在发布时崩溃。

我尝试评论这些行

 <replaceregexp
        byline="true"
        file="AndroidManifest.xml"
        match="android:label=&quot;/*.*&quot;"
        replace="android:label=&quot;${app.newappname}&quot;" >
    </replaceregexp>

它工作正常;这意味着这些线路有问题。

0 个答案:

没有答案