Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c60e9a3 authored by Bill Gruber's avatar Bill Gruber Committed by Scott Main
Browse files

docs cherrypick from hc-mr2: Change-Id: Id8dd0a0baa2fcc88bcfc8171e2be5882d0f06479

Doc update: publishing topics
Also fixes bug 5279672

Change-Id: Ifb06f7f56ee372a9680a63bdb659f495698fe794
parent 56539858
Loading
Loading
Loading
Loading
+53 −55
Original line number Diff line number Diff line
@@ -11,57 +11,54 @@ page.title=Introduction
  will sometimes have to call command line tools manually, but you will have access to the same
  number of features that you would have in Eclipse.</p>

  <p class="note"><strong>Note:</strong> Before you begin developing Android applications, make
    sure you have gone through all of the steps outlined in <a
href="{@docRoot}sdk/installing.html">Installing the SDK</a>.</p>

  <p>The basic steps for developing applications with or without Eclipse are the same:</p>

  <ol>

    <li>Set up Android Virtual Devices or hardware devices.
<div class="figure" style="width:461px">
  <img src="{@docRoot}images/developing/developing_overview.png"
       alt="Development process for Android applications"
       height="738" />
  <p class="img-caption">
    <strong>Figure 1.</strong> The development process for Android applications.
  </p>
</div>

      <p>You need to create Android Virtual Devices (AVD) or connect hardware devices on which
      you will install your applications.</p>
<p>The basic steps for developing applications (with or without Eclipse) are shown in figure 1. The
development steps encompass four development phases, which include:</p>

<ul>
  <li><strong>Setup</strong>
    <p>During this phase you install and set up your development environment. You also create
      Android Virtual Devices (AVDs) and connect hardware devices on which you can install your
      applications.</p>
    <p>See <a href="{@docRoot}guide/developing/devices/index.html">Managing Virtual Devices</a>
      and <a href="{@docRoot}guide/developing/device.html">Using Hardware Devices</a> for more
      information.
  </li>

    <li>
      <a href="{@docRoot}guide/developing/projects/index.html">Create an Android project</a>.

      <p>An Android project contains all source code and resource files for your application. It is
      built into an <code>.apk</code> package that you can install on Android devices.</p>
    </li>

    <li>
      <a href="{@docRoot}guide/developing/building/index.html">Build and run your
      application</a>.

      <p>If you are using Eclipse, builds are generated each time you save changes and you can install
      your application on a device by clicking <strong>Run</strong>. If you're using another IDE, you can build your
      project using Ant and install it on a device using <code>adb</code>.</p>
  <li><strong>Development</strong>
    <p>During this phase you set up and develop your Android project, which contains all of the
    source code and resource files for your application. For more informations, see
    <a href="{@docRoot}guide/developing/projects/index.html">Create an Android project</a>.</p>
  </li>

    <li>
  <li><strong>Debugging and Testing</strong>
    <p>During this phase you build your project into a debuggable <code>.apk</code> package that you
    can install and run on the emulator or an Android-powered device. If you are using Eclipse,
    builds are generated each time you project is saved. If you're using another IDE,
    you can build your project using Ant and install it on a device using
    <a href="{@docRoot}guide/developing/tools/adb.html">adb</a>. For more information, see
    <a href="{@docRoot}guide/developing/building/index.html">Build and run your application</a>.</p>
    <p>Next, you debug your application using a JDWP-compliant debugger along with the debugging
    and logging tools that are provided with the Android SDK. Eclipse already comes packaged with
    a compatible debugger. For more information see,
    <a href="{@docRoot}guide/developing/debugging/index.html">Debug your application with the
      SDK debugging and logging tools</a>.

      <p>Debugging your application involves using a JDWP-compliant debugger along with the
      debugging and logging tools that are provided with the Android SDK. Eclipse already
      comes packaged with a compatible debugger.</p>
      SDK debugging and logging tools</a>.</p>
    <p>Last, you test your application using various Android SDK testing tools. For more
    information, see <a href="{@docRoot}guide/developing/testing/index.html">Test your application
    with the Testing and Instrumentation framework</a>.</p>
  </li>

    <li>
      <a href="{@docRoot}guide/developing/testing/index.html">Test your application with the
      Testing and Instrumentation framework</a>.

      <p>The Android SDK provides a testing and instrumnetation framework to help you set up and
      run tests within an emulator or device.</p>
  <li><strong>Publishing</strong>
    <p>During this phase you configure and build your application for release and distribute your
      application to users. For more information, see
      <a href="{@docRoot}guide/publishing/publishing_overview.html">Publishing Overview</a>.</p>
  </li>
  </ol>
</ul>

<h2 id="EssentialTools">Essential command line tools</h2>

@@ -121,7 +118,8 @@ Jarsigner to
</p>
<h3 id="IntelliJ">Developing in IntelliJ IDEA</h3>
<div style="float: right">
<img alt="The IntelliJ graphical user interface" height="500px" src="{@docRoot}images/developing/intellijidea_android_ide.png"/>
<img alt="The IntelliJ graphical user interface" height="500px"
src="{@docRoot}images/developing/intellijidea_android_ide.png"/>
</div>
<p>
	IntelliJ IDEA is a powerful Java IDE from JetBrains that provides
+22 −16
Original line number Diff line number Diff line
@@ -406,6 +406,9 @@
      <span class="en">Android Market Topics</span>
    </h2>
    <ul>
      <li><a href="<?cs var:toroot ?>guide/publishing/publishing.html">
          <span class="en">Publishing on Android Market</span>
          </a></li>
      <li><a href="<?cs var:toroot ?>guide/publishing/licensing.html">
          <span class="en">Application Licensing</span></a>
      </li>
@@ -649,11 +652,25 @@
        <span class="zh-TW" style="display:none">發佈</span>
    </h2>
    <ul>
      <li><a href="<?cs var:toroot ?>guide/publishing/publishing_overview.html">
            <span class="en">Publishing Overview</span>
          </a><span class="new">new!</span></li>
      <li><a href="<?cs var:toroot ?>guide/publishing/preparing.html">
            <span class="en">Preparing for Release</span>
            <span class="de" style="display:none">Vorbereitung auf die Veröffentlichung</span>
            <span class="es" style="display:none">Publicación de aplicaciones</span>
            <span class="fr" style="display:none">Préparation à la publication</span>
            <span class="it" style="display:none">Preparativi per la pubblicazione</span>
            <span class="ja" style="display:none">公開の準備</span>
            <span class="zh-CN" style="display:none">准备发布</span>
            <span class="zh-TW" style="display:none">準備發佈</span>
          </a><span class="new">updated</span></li>
      <li><a href="<?cs var:toroot ?>guide/publishing/app-signing.html">
            <span class="en">Signing Your Applications</span>
            <span class="de" style="display:none">Signieren Ihrer Anwendungen</span>
            <span class="es" style="display:none">Firma de aplicaciones</span>
            <span class="fr" style="display:none">Attribution de votre signature <br />à vos applications</span>
            <span class="fr" style="display:none">Attribution de votre signature <br />à vos
applications</span>
            <span class="it" style="display:none">Firma delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションへの署名</span>
            <span class="zh-CN" style="display:none">应用程序签名</span>
@@ -661,27 +678,16 @@
          </a></li>
      <li><a href="<?cs var:toroot ?>guide/publishing/versioning.html">
            <span class="en">Versioning Your Applications</span>
            <span class="de" style="display:none">Versionsverwaltung für Ihre <br />Anwendungen</span>
            <span class="de" style="display:none">Versionsverwaltung für Ihre <br
/>Anwendungen</span>
            <span class="es" style="display:none">Versiones de las aplicaciones</span>
            <span class="fr" style="display:none">Attribution d'une version à vos applications</span>
            <span class="fr" style="display:none">Attribution d'une version à vos
applications</span>
            <span class="it" style="display:none">Controllo versioni delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションのバージョニング</span>
            <span class="zh-CN" style="display:none">应用程序版本控制</span>
            <span class="zh-TW" style="display:none">應用程式版本設定</span>
          </a></li>
      <li><a href="<?cs var:toroot ?>guide/publishing/preparing.html">
            <span class="en">Preparing to Publish</span>
            <span class="de" style="display:none">Vorbereitung auf die Veröffentlichung</span>
            <span class="es" style="display:none">Publicación de aplicaciones</span>
            <span class="fr" style="display:none">Préparation à la publication</span>
            <span class="it" style="display:none">Preparativi per la pubblicazione</span>
            <span class="ja" style="display:none">公開の準備</span>
            <span class="zh-CN" style="display:none">准备发布</span>
            <span class="zh-TW" style="display:none">準備發佈</span>
          </a></li>
      <li><a href="<?cs var:toroot ?>guide/publishing/publishing.html">
            <span class="en">Publishing on Android Market</span>
          </a></li>
    </ul>
  </li>

+142 −153
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ page.title=Signing Your Applications
<h2>Quickview</h2>

<ul>
<li>All Android apps <em>must</em> be signed</a></li>
<li>All Android apps <em>must</em> be signed</li>
<li>You can sign with a self-signed key</li>
<li>How you sign your apps is critical &mdash; read this document carefully</li>
<li>Determine your signing strategy early in the development process</li>
@@ -16,11 +16,11 @@ page.title=Signing Your Applications
<h2>In this document</h2>

<ol>
<li><a href="#overview">Overview</a></li>
<li><a href="#signing">Signing Process</a></li>
<li><a href="#strategies">Signing Strategies</a></li>
<li><a href="#setup">Basic Setup for Signing</a></li>
<li><a href="#debugmode">Signing in Debug Mode</a></li>
<li><a href="#releasemode">Signing for Public Release</a>
<li><a href="#releasemode">Signing Release Mode</a>
    <ol>
    <li><a href="#cert">Obtain a suitable private key</a></li>
    <li><a href="#releasecompile">Compile the application in release mode</a></li>
@@ -43,74 +43,67 @@ page.title=Signing Your Applications
</div>
</div>

<p>This document provides information about signing your Android applications prior to publishing them for mobile device users.</p>

<h2 id="overview">Overview</h2>

<p>The Android system requires that all installed applications be digitally
signed with a certificate whose private key is held by the application's
developer. The Android system uses the certificate as a means of identifying the author of
an application and establishing trust relationships between applications. The certificate is not
used to control which applications the user can install. The certificate
does not need to be signed by a certificate authority: it is perfectly
allowable, and typical, for Android applications to use self-signed
certificates.</p>
<p>The Android system requires that all installed applications be digitally signed with a
certificate whose private key is held by the application's developer. The Android system uses the
certificate as a means of identifying the author of an application and establishing trust
relationships between applications. The certificate is not used to control which applications the
user can install. The certificate does not need to be signed by a certificate authority: it is
perfectly allowable, and typical, for Android applications to use self-signed certificates.</p>

<p>The important points to understand about signing Android applications are:</p>

<ul>
  <li>All applications <em>must</em> be signed. The system will not install an application
that is not signed.</li>
  <li>You can use self-signed certificates to sign your applications. No certificate authority 
is needed.</li>
  <li>When you are ready to release your application for end-users, you must sign it with a suitable private 
key. You can not publish an application that is signed with the debug key generated 
by the SDK tools. 
  </li>
on an emulator or a device if it is not signed.</li>
  <li>To test and debug your application, the build tools sign your application with a special debug
    key that is created by the Android SDK build tools.</li>
  <li>When you are ready to release your application for end-users, you must sign it with a suitable
    private key. You cannot publish an application that is signed with the debug key generated
    by the SDK tools.</li>
  <li>You can use self-signed certificates to sign your applications. No certificate authority is
    needed.</li>
  <li>The system tests a signer certificate's expiration date only at install time. If an
application's signer certificate expires after the application is installed, the application
will continue to function normally.</li>
  <li>You can use standard tools &mdash; Keytool and Jarsigner &mdash; to generate keys and
sign your application .apk files.</li>
  <li>Once you have signed the application, use the <code>zipalign</code> tool to optimize the final APK package.</li>
  <li>After you sign your application for release, we recommend that you use the
    <code>zipalign</code> tool to optimize the final APK package.</li>
</ul>

<p>The Android system will not install or run an application that is not signed appropriately. This
applies wherever the Android system is run, whether on an actual device or on the emulator.
For this reason, you must set up signing for your application before you will be able to 
run or debug it on an emulator or device.</p>

<p>The Android SDK tools assist you in signing your applications when debugging. Both the ADT Plugin 
for Eclipse and the Ant build tool offer two signing modes &mdash; <em>debug mode</em> 
and <em>release mode</em>. 

<ul>
<li>While developing and testing, you can compile in debug mode. 
In debug mode, the build tools use the Keytool utility, included in the JDK, to create 
a keystore and key with a known alias and password. At each compilation, the tools then use 
the debug key to sign the application .apk file. Because the password is known, the tools 
don't need to prompt you for the keystore/key password each time you compile.</li>

<li>When your application is ready for release, you must compile in release mode
and then sign the .apk <span style="color:red">with your private key</span>. 
There are two ways to do this:
  <ul>
    <li>Using Keytool and Jarsigner in the command-line. In this approach,
    you first compile your application to an <em>unsigned</em> .apk. You must then sign
    the .apk manually with your private key
    using Jarsigner (or similar tool). If you do not have a suitable private key already, 
    you can run Keytool manually to generate your own keystore/key and then sign your 
    application with Jarsigner.</li>
    <li>Using the ADT Export Wizard. If you are developing in Eclipse with the ADT plugin, 
    you can use the Export Wizard to compile the application, generate a private key 
    (if necessary), and sign the .apk, all in a single process using the Export Wizard.
    </li>
  </ul>
</li>
</ul>

<p>Once your application is signed, don't forget to run {@code zipalign} on the APK
for additional optimization.</p>
For this reason, you must <a href="#setup">set up signing</a> for your application before you can
run it or debug it on an emulator or device.</p>

<h2 id="signing">Signing Process</h3>

<p>The Android build process signs your application differently depending on which build mode you
use to build your application. There are two build modes: <em>debug mode</em> and <em>release
mode</em>. You use debug mode when you are developing and testing your application. You use
release mode when you want to build a release version of your application that you can
distribute directly to users or publish on an application marketplace such as Android Market.</p>

<p>When you build in <em>debug mode</em> the Android SDK build tools use the Keytool utility
(included in the JDK) to create a debug key. Because the SDK build tools created the debug key,
they know the debug key's alias and password. Each time you compile your application in debug mode,
the build tools use the debug key along with the Jarsigner utility (also included in the JDK) to
sign your application's <code>.apk</code> file. Because the alias and password are known to the SDK
build tools, the tools don't need to prompt you for the debug key's alias and password each time
you compile.</p>

<p>When you build in <em>release mode</em> you use your own private key to sign your application. If
you don't have a private key, you can use the Keytool utility to create one for you. When you
compile your application in release mode, the build tools use your private key along with the
Jarsigner utility to sign your application's <code>.apk</code> file. Because the certificate and
private key you use are your own, you will have to provide the password for the keystore and key
alias.</p>

<p>The debug signing process happens automatically when you run or debug your application using
Eclipse with the ADT plugin. Debug signing also happens automatically when you use the Ant build
script with the <code>debug</code> option. You can automate the release signing process by using the
Eclipse Export Wizard or by modifying the Ant build script and building with the
<code>release</code> option.</p>

<h2 id="strategies">Signing Strategies</h2>

@@ -177,11 +170,11 @@ use a <a href="#cert">suitable certificate</a> to sign your applications. </p>

<h2 id="setup">Basic Setup for Signing</h2>

<p>Before you begin, you should make sure that 
Keytool is available to the SDK build 
tools. In most cases, you can tell the SDK build tools how to find Keytool by setting
your <code>JAVA_HOME</code> environment variable to references a suitable JDK. 
Alternatively, you can add the JDK version of Keytool to your <code>PATH</code> variable.</p>
<p>Before you begin, make sure that the Keytool utility and Jarsigner utility are available to
the SDK build tools. Both of these tools are available in the JDK. In most cases, you can tell
the SDK build tools how to find these utilities by setting your <code>JAVA_HOME</code> environment
variable so it references a suitable JDK. Alternatively, you can add the JDK version of Keytool and
Jarsigner to your <code>PATH</code> variable.</p>

<p>If you are developing on a version of Linux that originally came with GNU Compiler for
Java, make sure that the system is using the JDK version of Keytool, rather than the gcj
@@ -189,10 +182,6 @@ version. If Keytool is already in your <code>PATH</code>, it might be pointing t
<code>/usr/bin/keytool</code>. In this case, check the symlink target to be sure it points
to the Keytool in the JDK.</p>

<p>If you will release your application to the public, you will also need to have
the Jarsigner tool available on your machine. Both Jarsigner and Keytool are included
in the JDK. </p>

<h2 id="debugmode">Signing in Debug Mode</h2>

<p>The Android build tools provide a debug signing mode that makes it easier for you
@@ -209,7 +198,7 @@ you do not need to sign the package with your own key.</p>
<li>Key alias: "androiddebugkey"</li>
<li>Key password: "android"</li>
<li>CN: "CN=Android Debug,O=Android,C=US"</li>
</ul></p>
</ul>

<p>If necessary, you can change the location/name of the debug keystore/key or
supply a custom debug keystore/key to use. However, any custom debug
@@ -223,7 +212,7 @@ to the public when signed with the debug certificate.</p>

<h3>Eclipse Users</h3>

<p>If you are developing in Eclipse/ADT (and have set up Keytool as described above in 
<p>If you are developing in Eclipse/ADT (and have set up Keytool and Jarsigner as described above in
<a href="#setup">Basic Setup for Signing</a>),
signing in debug mode is enabled by default. When you run or debug your
application, ADT signs the .apk with the debug certificate, runs {@code zipalign} on the
@@ -274,12 +263,12 @@ I&nbsp;can't&nbsp;compile my app because the build tools generated an expired de
certificate</a>. </p>


<h2 id="releasemode">Signing for Public Release</h2>
<h2 id="releasemode">Signing in Release Mode</h2>

<p>When your application is ready for release to other users, you must:</p>
<ol>
  <li><a href="#cert">Obtain a suitable private key</a></li>
  <li><a href="#releasecompile">Compile the application in release mode</li>
  <li><a href="#releasecompile">Compile the application in release mode</a></li>
  <li><a href="#signapp">Sign your application with your private key</a></li>
  <li><a href="#align">Align the final APK package</a></li>
</ol>
@@ -455,7 +444,7 @@ the keystore containing your private key is available.</p>

<p>To sign your application, you run Jarsigner, referencing both the
application's .apk and the keystore containing the private key with which to
sign the .apk. The table below shows the options you could use. <p>
sign the .apk. The table below shows the options you could use. </p>

<table>
<tr>
+331 −229

File changed.

Preview size limit exceeded, changes collapsed.

+236 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading