Signing packages

From Android Wiki

(Difference between revisions)
Jump to: navigation, searcha
 
Line 36: Line 36:
Now I can just type
Now I can just type
-
[http://www.burberrybags-sale.com burberry bags]
 
<code>
<code>
Line 47: Line 46:
[[Category:Programming]]
[[Category:Programming]]
-
 
-
 
-
'''Source(s):'''  [http://www.downloadranking.com  Android solutions]
 

Latest revision as of 08:49, 31 January 2013

Once you have generated a key, the Google-recommended way of signing a package during a build is to use the jarsigner tool.

The standard Ant build scripts are supposed to allow you to automate signing packages. However, I had some trouble with this, so I am currently including explicit signjar and zipalign commands in my build.xml. I also add a file called keystore.properties to my source directory, which I exclude from version control, because it contains my keystore password. This defines three custom properties that I use in the signjar command:

keystore.path=keystorename
keystore.alias=keyalias
keystore.password=keystorepassword

Then in my build.xml, I include this properties file somewhere convenient (e.g. just after the inclusion of local.properties):

    <property file="keystore.properties" />

And then I define a new target called signed, which depends on the standard -package-release target, as follows:

    <target name="signed" depends="-package-release">
        <signjar
            keystore="${keystore.path}" alias="${keystore.alias}" storepass="${keystore.password}"
            jar="bin/${ant.project.name}-unsigned.apk"
            signedjar="bin/${ant.project.name}-unaligned.apk"
            verbose="true"
        />
        <exec executable="${sdk.dir}/tools/zipalign">
            <arg value="-f"/>
            <arg value="-v"/>
            <arg value="4"/>
            <arg value="bin/${ant.project.name}-unaligned.apk"/>
            <arg value="bin/${ant.project.name}.apk"/>
        </exec>
    </target>

Now I can just type

ant signed

to automatically invoke the compilation, packaging, signing and aligning steps.

For a fully-worked example of this in action, see the source code to ti5x_android.

Personal tools