From 1362dad293cefae8bcf096592ab512afba28d395 Mon Sep 17 00:00:00 2001 From: Scott Main <> Date: Tue, 21 Apr 2009 14:29:14 -0700 Subject: [PATCH] AI 147225: am: CL 147224 am: CL 147219 update app-signing doc to include a guide to export a signed APK from ADT Original author: smain Merged from: //branches/cupcake/... Original author: android-build Automated import of CL 147225 --- docs/html/guide/publishing/app-signing.jd | 189 ++++++++++++++-------- 1 file changed, 126 insertions(+), 63 deletions(-) diff --git a/docs/html/guide/publishing/app-signing.jd b/docs/html/guide/publishing/app-signing.jd index 28c927aed29c5..a16c9106ad931 100644 --- a/docs/html/guide/publishing/app-signing.jd +++ b/docs/html/guide/publishing/app-signing.jd @@ -22,9 +22,10 @@ page.title=Signing Your Applications
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 system uses the certificate as a means of identifying the author of -an application and establishing trust relationships between applications, rather -than for controlling which applications the user can install. The certificate +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.
@@ -61,8 +62,8 @@ certificates. that is not signed.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 — debug mode and release mode. +for Eclipse and the Ant build tool offer two signing modes — debug mode +and release mode.
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
version. If Keytool is already in your PATH, it might be pointing to a symlink at
-/usr/bin/keytool. In this case, check the symlink target to make sure that it points
+/usr/bin/keytool. In this case, check the symlink target to make sure that it points
to the Keytool in the JDK.
If you will release your application to the public, you will also need to have @@ -180,38 +193,46 @@ in the JDK.
to develop and debug your application, while still meeting the Android system requirement for signing your .apk when it is installed in the emulator or a device. When you use debug mode, the SDK tools invoke Keytool to create a debug -keystore and key. +keystore and key.The SDK tools create the debug keystore/key with predetermined names/passwords;
If necessary, you can change the location/name of the debug keystore/key or +supply a custom debug keystore/key to use. In Eclipse/ADT, you can use +Windows > Prefs > +Android > Build. However, any custom debug +keystore/key must use the same keystore/key names and passwords as the default +debug key (as described above).
+ +Note: You cannot release your application +to the public when signed with the debug certificate.
+ +If you are developing in Eclipse/ADT and have set up Keytool as described above, signing in debug mode is enabled by default. When you run or debug your application, ADT signs the .apk with the debug certificate and installs it on the emulator. No specific action on your part is needed, provided ADT has access to Keytool.
+If you use Ant to build your .apk files, debug signing mode
-is enabled by default, assuming that you are using a build.xml file generated by the
-activitycreator tool included in the latest SDK. When you run Ant against build.xml to
+is enabled by using the debug option, assuming that you are using a
+build.xml file generated by the
+android tool. When you run ant debug to
compile your app, the build script generates a keystore/key and signs the .apk for you.
-No specific action on your part is needed.
If necessary, you can change the location/name of the debug keystore/key or -supply a custom debug keystore/key to use. In Eclipse/ADT, you can use -Windows > Prefs > -Android > Build. However, any custom debug -keystore/key must use the same keystore/key names and passwords as the default -debug key (as described above).
- -Note that you cannot release your application to the public if it -is signed with the debug certificate.
In Eclipse/ADT, you will see a similar error in the Android console.
-To fix this problem, simply delete the debug.keystore file. On Linux/Mac OSX,
-the file is stored in ~/.android. On Windows XP, the file is stored in
-C:\Documents and Settings\<user>\Local Settings\Application Data\Android.
-On Windows Vista, the file is stored in
-C:\Users\<user>\AppData\Local\Android.
To fix this problem, simply delete the debug.keystore file.
+The default storage location for AVDs is in ~/.android/avd on OS X and Linux,
+in C:\Documents and Settings\ on Windows XP, and in
+C:\Users\ on Windows Vista.
The next time you build, the build tools will regenerate a new keystore and debug key.
@@ -242,29 +263,45 @@ troubleshooting topic Signing for Public ReleaseWhen your application is ready for release to other users, you must:
The sections below provide information about these steps.
+The sections below provide information about how to perform these steps.
-If you use Eclipse with the ADT plugin, you can instead use the Export Wizard +to compile and sign an .apk with your private key. The Export Wizard even allows you to +generate a new keystore and private key in the process. Skip to +Compiling and signing with Eclipse ADT.
+ + +To prepare your application for release, you must first compile it in release mode. In release mode, the Android build tools compile your application as usual, -but without signing it with the debug key.
+but without signing it with the debug key. -If you are developing in Eclipse/ADT, right-click the project in the Package -pane and select Android Tools > Export Application -Package. You can then specify the file location for the unsigned .apk. -Alternatively, you can follow the "Exporting the unsigned .apk" -link in the Manifest Editor overview page.
+Note: +You can not release your application unsigned, or signed with the debug key.
+ +To export an unsigned .apk from Eclipse, right-click the project in the Package
+Explorer and select Android Tools > Export Unsigned Application
+Package. Then simply specify the file location for the unsigned .apk.
+(Alternatively, open your AndroidManifest.xml file in Eclipse, open
+the Overview tab, and click Export an unsigned .apk.)
You can also combine the compiling and signing steps with the Export Wizard. See +Compiling and signing with Eclipse ADT.
+ +If you are using Ant, all you need to do is specify the build target "release" in the Ant command. For example, if you are running Ant from the @@ -272,9 +309,8 @@ directory containing your build.xml file, the command would look like this:
$ ant release-
The build script compiles the application .apk without signing it. +
The build script compiles the application .apk without signing it.
-Note that you can not release your application unsigned, or signed with the debug key.
Before you run Keytool, make sure to read +
Note: Before you run Keytool, make sure to read Securing Your Private Key for a discussion of how to keep your key secure and why doing so is critically important to you and to users. In particular, when you are generating your key, you should select strong passwords @@ -378,7 +414,8 @@ will use later, to refer to this keystore when signing your application.
href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security"> http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security -When you are ready to actually sign your .apk for release, you can do so using the Jarsigner tool. Make sure that you have Jarsigner available on your @@ -425,9 +462,9 @@ way, your password is not stored in your shell history.
my_application.apk alias_nameRunning the example command above, Jarsigner prompts you to provide -passwords for the keystore and key. It then modifies the APK +passwords for the keystore and key. It then modifies the .apk in-place, meaning the .apk is now signed. Note that you can sign an -APK multiple times with different keys.
+.apk multiple times with different keys.To verify that your .apk is signed, you can use a command like this:
@@ -445,7 +482,7 @@ If you want more details, you can try one of these commands:The command above, with the -certs option added, will show you the
"CN=" line that describes who created the key.
Note: if you see "CN=Android Debug", this means the .apk was +
Note: If you see "CN=Android Debug", this means the .apk was signed with the debug key generated by the Android SDK. If you intend to release your application, you must sign it with your private key instead of the debug key.
@@ -454,6 +491,32 @@ key. http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security + +When using Eclipse with ADT, you can use the Export Wizard to +export a signed .apk (and even create a new keystore, +if necessary). The Export Wizard performs all the interaction with +the Keytool and Jarsigner for you, which allows you to perform signing via a +graphical interface instead of the command-line. +Because the Export Wizard uses both Keytool and Jarsigner, you should +ensure that they are accessible on your computer, as described above +in the Basic Setup for Signing.
+ +To create a signed .apk, right-click the project in the Package
+Explorer and select Android Tools > Export Signed Application Package.
+(Alternatively, open your AndroidManifest.xml file in Eclipse, open
+the Overview tab, and click Use the Export Wizard.)
+The window that appears will display any errors found while
+attempting to export your application. If no errors are found, continue with the
+Export Wizard, which will guide you through the process of signing your application,
+including steps for selecting the private key with which to sign the .apk,
+or creating a new keystore and private key.
When you complete the Export Wizard, you'll +have a signed .apk that's ready for distribution.
+ +Maintaining the security of your private key is of critical importance, both