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):
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>
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.
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