Android Signing with Ant

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.

Signing Android application using ANT

You should just create an ant.properties file in your main project directory. Then edit it to be like my answer to this question:

signing applications automatically with password in ant

signing applications automatically with password in ant

I just have these lines in my ant.properties and it signs automatically

key.store.password=mypasswordOne
key.alias.password=mypasswordTwo
key.store=c:/users/myname/my-release-key.keystore
key.alias=release_alias

Building both signed and unsigned releases with Ant

You don't need to zipalign the package, because, according to this question, amazon will zipalign the package after they sign it.

And according to this page on the Android developer site, zip aligning of the unsigned package is useless, because the signing operation that amazon will do will de-align the package.

Ant Build Signing Jar

It looks like you have to add the following in the /tools/ant/build.xml

<signjar
sigalg="MD5withRSA"
digestalg="SHA1">

Building Android APK with Ant ignores signing password

I've solved the problem - the keystore password and alias password were identical. This seemed to allow the signing process using ant to pass when entering the wrong password for the alias.

If I make the passwords differ, the build process does indeed fail if the wrong alias password is entered.



Related Topics



Leave a reply



Submit