Android signing with Ant Android signing with Ant android android

Android signing with Ant


If you have Ant version < 1.8.3 (ant -version) try this approach for the issue with JDK 7 (based on the previous answer):

  1. Add signjarjdk7 to ANDROID_SDK\tools\ant\build.xml

    <macrodef name="signjarjdk7">    <attribute name="jar" />    <attribute name="signedjar" />    <attribute name="keystore" />    <attribute name="storepass" />    <attribute name="alias" />    <attribute name="keypass" />    <attribute name="verbose" />    <sequential>        <exec executable="jarsigner" failonerror="true">            <!-- Magic key, always verbose -->            <arg line="-verbose -digestalg SHA1 -sigalg MD5withRSA" />            <arg line="-keystore @{keystore} -storepass @{storepass} -keypass @{keypass}" />            <arg line="-signedjar "@{signedjar}"" />            <arg line=""@{jar}" @{alias}" />        </exec>    </sequential></macrodef>
  2. Replace 'signjar' to 'signjarjdk7' in 'release' target in the same build.xml.

NOTE: You have to define 'key.store.password' and 'key.alias.password' propeties for your project (in project.properties or in local.properties).

UPDATE 1:

If your have installed Ant 1.8.3 (or later) you have a better solution:

Open your ANDROID_SDK\tools\ant\build.xml and add two new parameters - sigalg and digestalg - in the original 'signjar' invocation:

<signjar    sigalg="MD5withRSA"    digestalg="SHA1"    jar="${out.packaged.file}"    signedjar="${out.unaligned.file}"    keystore="${key.store}"    storepass="${key.store.password}"    alias="${key.alias}"    keypass="${key.alias.password}"    verbose="${verbose}" />

UPDATE 2:It seems this answer is deprecated after 'signjar' was replaced to 'signapk' in latest version of Android SDK tools.


It sounds as you may be using JDK 7 (1.7.0) so try adding these options when signing with jarsigner:

-digestalg SHA1 -sigalg MD5withRSA


Per Android developer documentation, you should put these properties within the ant.properties file:

$ cat ant.propertieskey.store=C:\\Users\\a512091\\.android\\release.keystorekey.alias=applicationkey.store.password=androidkey.alias.password=android