2012-02-15 9 views
3

myapp-release.apkからmyapp-1.0.30.apkへの私のapkの名前を変更したいとします。私はbuild.xmlでこれをやりたい私はマニフェストのバージョンを読んでから、apkの名前を変更したいと思います。 私はantを使用しています。
antを使用してbuild.xmlのmanifest.xmlからバージョンコードを読み取る方法

<macrodef name="mfgrep"> 
    <attribute name="jar"/> 
    <attribute name="key"/> 
    <attribute name="keysave"/> 
    <sequential> 
     <loadproperties> 
     <zipentry zipfile="@{jar}" name="META-INF/MANIFEST.MF"/> 
     </loadproperties> 
     <echo>@{key} => ${@{key}}</echo> 
     <property name="@{keysave}" value="${@{key}}"/> 
    </sequential> 
</macrodef> 

<!-- Grep a key from Manifest --> 
<mfgrep 
    jar="/home/gilreb/temp/test.jar" 
    key="Specification-Version" 
    keysave="foobar" 
/> 

は、その後、あなたのファイルの名前を変更するために、プロパティ$ {foobarという}を使用します:

おかげで、 スネハ

答えて

4

私自身の質問への回答:

<path id="android.antlibs"> 
      <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" /> 
</path> 
<taskdef name="xpath" classname="com.android.ant.XPathTask" classpathref="android.antlibs" /> 
<xpath input="./AndroidManifest.xml" expression="/manifest/@android:versionName" output="manifest.versionName" /> 
<echo message="versionName = ${manifest.versionName}" /> 
+1

私の場合、jarは$ {sdk.dir} /tools/lib/ant-tasks.jarにあります:) –

関連する問題