@@ -66,7 +66,7 @@ on an emulator or a device if it is not signed.</li>
6666application's signer certificate expires after the application is installed, the application
6767will continue to function normally.</li>
6868 <li>You can use standard tools — Keytool and Jarsigner — to generate keys and
69- sign your application .apk files.</li>
69+ sign your application {@code .apk} files.</li>
7070 <li>After you sign your application for release, we recommend that you use the
7171 <code>zipalign</code> tool to optimize the final APK package.</li>
7272</ul>
@@ -186,9 +186,9 @@ to the Keytool in the JDK.</p>
186186
187187<p>The Android build tools provide a debug signing mode that makes it easier for you
188188to develop and debug your application, while still meeting the Android system
189- requirement for signing your .apk .
189+ requirement for signing your APK .
190190When using debug mode to build your app, the SDK tools invoke Keytool to automatically create
191- a debug keystore and key. This debug key is then used to automatically sign the .apk , so
191+ a debug keystore and key. This debug key is then used to automatically sign the APK , so
192192you do not need to sign the package with your own key.</p>
193193
194194<p>The SDK tools create the debug keystore/key with predetermined names/passwords:</p>
@@ -215,19 +215,19 @@ to the public when signed with the debug certificate.</p>
215215<p>If you are developing in Eclipse/ADT (and have set up Keytool and Jarsigner as described above in
216216<a href="#setup">Basic Setup for Signing</a>),
217217signing in debug mode is enabled by default. When you run or debug your
218- application, ADT signs the .apk with the debug certificate, runs {@code zipalign} on the
219- package, then installs it on
218+ application, ADT signs the {@code .apk} file with the debug certificate, runs {@code zipalign} on
219+ the package, then installs it on
220220the selected emulator or connected device. No specific action on your part is needed,
221221provided ADT has access to Keytool.</p>
222222
223223<h3>Ant Users</h3>
224224
225- <p>If you are using Ant to build your .apk files , debug signing mode
225+ <p>If you are using Ant to build your {@code .apk} file , debug signing mode
226226is enabled by using the <code>debug</code> option with the <code>ant</code> command
227227(assuming that you are using a <code>build.xml</code> file generated by the
228228<code>android</code> tool). When you run <code>ant debug</code> to
229- compile your app, the build script generates a keystore/key and signs the .apk for you.
230- The script then also aligns the .apk with the <code>zipalign</code> tool.
229+ compile your app, the build script generates a keystore/key and signs the APK for you.
230+ The script then also aligns the APK with the <code>zipalign</code> tool.
231231No other action on your part is needed. Read
232232<a href="{@docRoot}guide/developing/building/building-cmdline.html#DebugMode">Building and Running Apps
233233on the Command Line</a> for more information.</p>
@@ -383,8 +383,8 @@ will use later, to refer to this keystore when signing your application. </p>
383383
384384<p>For more information about Keytool, see the documentation at
385385<a
386- href="http://java.sun .com/j2se/1.5.0 /docs/tooldocs/#security ">
387- http://java.sun .com/j2se/1.5.0 /docs/tooldocs/#security </a></p>
386+ href="http://docs.oracle .com/javase/6 /docs/technotes/tools/windows/keytool.html ">
387+ http://docs.oracle .com/javase/6 /docs/technotes/tools/windows/keytool.html </a></p>
388388
389389
390390
@@ -399,11 +399,11 @@ You can not release your application unsigned, or signed with the debug key.</p>
399399
400400<h4>With Eclipse</h4>
401401
402- <p>To export an <em>unsigned</em> .apk from Eclipse, right-click the project in the Package
402+ <p>To export an <em>unsigned</em> APK from Eclipse, right-click the project in the Package
403403Explorer and select <strong>Android Tools</strong> > <strong>Export Unsigned Application
404- Package</strong>. Then specify the file location for the unsigned .apk .
405- (Alternatively, open your <code>AndroidManifest.xml</code> file in Eclipse, open
406- the <em>Overview</em > tab, and click <strong>Export an unsigned .apk </strong>.)</p>
404+ Package</strong>. Then specify the file location for the unsigned APK .
405+ (Alternatively, open your <code>AndroidManifest.xml</code> file in Eclipse, select
406+ the <strong>Manifest</strong > tab, and click <strong>Export an unsigned APK </strong>.)</p>
407407
408408<p>Note that you can combine the compiling and signing steps with the Export Wizard. See
409409<a href="#ExportWizard">Compiling and signing with Eclipse ADT</a>.</p>
@@ -414,11 +414,11 @@ the <em>Overview</em> tab, and click <strong>Export an unsigned .apk</strong>.)<
414414with the <code>ant</code> command. For example, if you are running Ant from the
415415directory containing your {@code build.xml} file, the command would look like this:</p>
416416
417- <pre>ant release</pre>
417+ <pre>$ ant release</pre>
418418
419- <p>By default, the build script compiles the application .apk without signing it. The output file
419+ <p>By default, the build script compiles the application APK without signing it. The output file
420420in your project {@code bin/} will be <code><em><your_project_name></em>-unsigned.apk</code>.
421- Because the application .apk is still unsigned, you must manually sign it with your private
421+ Because the application APK is still unsigned, you must manually sign it with your private
422422key and then align it using {@code zipalign}.</p>
423423
424424<p>However, the Ant build script can also perform the signing
@@ -443,8 +443,8 @@ machine, as described in <a href="#setup">Basic Setup</a>. Also, make sure that
443443the keystore containing your private key is available.</p>
444444
445445<p>To sign your application, you run Jarsigner, referencing both the
446- application's .apk and the keystore containing the private key with which to
447- sign the .apk . The table below shows the options you could use. </p>
446+ application's APK and the keystore containing the private key with which to
447+ sign the APK . The table below shows the options you could use. </p>
448448
449449<table>
450450<tr>
@@ -459,6 +459,14 @@ the keystore containing your private key.</td>
459459<td><code>-verbose</code></td><td>Enable verbose output.</td>
460460</tr>
461461<tr>
462+ <td><code>-sigalg</code></td><td>The name of the signature algorithim to use in signing the APK.
463+ Use the value {@code MD5withRSA}.</td>
464+ </tr>
465+ <tr>
466+ <td><code>-digestalg</code></td><td>The message digest algorithim to use in processing the entries
467+ of an APK. Use the value {@code SHA1}.</td>
468+ </tr>
469+ <tr>
462470<td><code>-storepass <password></code></td><td><p>The password for the
463471keystore. </p><p>As a security precaution, do not include this option
464472in your command line unless you are working at a secure computer.
@@ -478,19 +486,23 @@ way, your password is not stored in your shell history.</p></td>
478486<code>my_application.apk</code>, using the example keystore created above.
479487</p>
480488
481- <pre>$ jarsigner -verbose -keystore my-release-key.keystore
489+ <pre>$ jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 - keystore my-release-key.keystore
482490my_application.apk alias_name</pre>
483491
484492<p>Running the example command above, Jarsigner prompts you to provide
485- passwords for the keystore and key. It then modifies the .apk
486- in-place, meaning the .apk is now signed. Note that you can sign an
487- .apk multiple times with different keys.</p>
493+ passwords for the keystore and key. It then modifies the APK
494+ in-place, meaning the APK is now signed. Note that you can sign an
495+ APK multiple times with different keys.</p>
496+
497+ <p class="caution"><strong>Caution:</strong> As of JDK 7, the default signing algorithim has
498+ changed, requiring you to specify the signature and digest algorithims ({@code -sigalg} and {@code
499+ -digestalg}) when you sign an APK.</p>
488500
489- <p>To verify that your .apk is signed, you can use a command like this:</p>
501+ <p>To verify that your APK is signed, you can use a command like this:</p>
490502
491503<pre>$ jarsigner -verify my_signed.apk</pre>
492504
493- <p>If the .apk is signed properly, Jarsigner prints "jar verified".
505+ <p>If the APK is signed properly, Jarsigner prints "jar verified".
494506If you want more details, you can try one of these commands:</p>
495507
496508<pre>$ jarsigner -verify -verbose my_application.apk</pre>
@@ -502,19 +514,19 @@ If you want more details, you can try one of these commands:</p>
502514<p>The command above, with the <code>-certs</code> option added, will show you the
503515"CN=" line that describes who created the key.</p>
504516
505- <p class="note"><strong>Note:</strong> If you see "CN=Android Debug", this means the .apk was
517+ <p class="note"><strong>Note:</strong> If you see "CN=Android Debug", this means the APK was
506518signed with the debug key generated by the Android SDK. If you intend to release
507519your application, you must sign it with your private key instead of the debug
508520key.</p>
509521
510522<p>For more information about Jarsigner, see the documentation at
511- <a href="http://java.sun .com/j2se/1.5.0 /docs/tooldocs/#security ">
512- http://java.sun .com/j2se/1.5.0 /docs/tooldocs/#security </a></p>
523+ <a href="http://docs.oracle .com/javase/6 /docs/technotes/tools/windows/jarsigner.html ">
524+ http://docs.oracle .com/javase/6 /docs/technotes/tools/windows/jarsigner.html </a></p>
513525
514526
515527<h3 id="align">4. Align the final APK package</h3>
516528
517- <p>Once you have signed the .apk with your private key, run <code>zipalign</code> on the file.
529+ <p>Once you have signed the APK with your private key, run <code>zipalign</code> on the file.
518530This tool ensures that all uncompressed data starts with a particular byte alignment,
519531relative to the start of the file. Ensuring alignment at 4-byte boundaries provides
520532a performance optimization when installed on a device. When aligned, the Android
@@ -524,16 +536,16 @@ of the data from the package. The benefit is a reduction in the amount of
524536RAM consumed by the running application.</p>
525537
526538<p>The <code>zipalign</code> tool is provided with the Android SDK, inside the
527- <code>tools/</code> directory. To align your signed .apk , execute:</p>
539+ <code>tools/</code> directory. To align your signed APK , execute:</p>
528540
529- <pre>zipalign -v 4 <em>your_project_name</em>-unaligned.apk <em>your_project_name</em>.apk</pre>
541+ <pre>$ zipalign -v 4 <em>your_project_name</em>-unaligned.apk <em>your_project_name</em>.apk</pre>
530542
531543<p>The {@code -v} flag turns on verbose output (optional). {@code 4} is the
532544byte-alignment (don't use anything other than 4). The first file argument is
533- your signed .apk (the input) and the second file is the destination .apk file (the output).
534- If you're overriding an existing .apk , add the {@code -f} flag.</p>
545+ your signed {@code .apk} file (the input) and the second file is the destination {@code .apk} file
546+ (the output). If you're overriding an existing APK , add the {@code -f} flag.</p>
535547
536- <p class="caution"><strong>Caution:</strong> Your input .apk must be signed with your
548+ <p class="caution"><strong>Caution:</strong> Your input APK must be signed with your
537549private key <strong>before</strong> you optimize the package with {@code zipalign}.
538550If you sign it after using {@code zipalign}, it will undo the alignment.</p>
539551
@@ -544,7 +556,7 @@ If you sign it after using {@code zipalign}, it will undo the alignment.</p>
544556<h3 id="ExportWizard">Compile and sign with Eclipse ADT</h3>
545557
546558<p>If you are using Eclipse with the ADT plugin, you can use the Export Wizard to
547- export a <em>signed</em> .apk (and even create a new keystore,
559+ export a <em>signed</em> APK (and even create a new keystore,
548560if necessary). The Export Wizard performs all the interaction with
549561the Keytool and Jarsigner for you, which allows you to sign the package using a GUI
550562instead of performing the manual procedures to compile, sign,
@@ -554,7 +566,7 @@ Because the Export Wizard uses both Keytool and Jarsigner, you should
554566ensure that they are accessible on your computer, as described above
555567in the <a href="#setup">Basic Setup for Signing</a>.</p>
556568
557- <p>To create a signed and aligned .apk in Eclipse:</p>
569+ <p>To create a signed and aligned APK in Eclipse:</p>
558570
559571<ol>
560572 <li>Select the project in the Package
@@ -563,7 +575,7 @@ Explorer and select <strong>File > Export</strong>.</li>
563575 and click <strong>Next</strong>.
564576 <p>The Export Android Application wizard now starts, which will
565577 guide you through the process of signing your application,
566- including steps for selecting the private key with which to sign the .apk
578+ including steps for selecting the private key with which to sign the APK
567579 (or creating a new keystore and private key).</p>
568580 <li>Complete the Export Wizard and your application will be compiled,
569581 signed, aligned, and ready for distribution.</li>
0 commit comments