Signing Your Applications

Signing quickview

  • All Android apps must be signed
  • You can sign with a self-signed key
  • How you sign your apps is critical read this document carefully
  • Determine your signing strategy early in the development process

In this document

  1. Overview
  2. Signing Strategies
  3. Basic Setup for Signing
  4. Signing in Debug Mode
  5. Signing for Public Release
    1. Obtain a suitable private key
    2. Compile the application in release mode
    3. Sign your application with your private key
    4. Align the final APK package
    5. Compile and sign with Eclipse ADT
  6. Securing Your Private Key

See also

  1. Versioning Your Applications
  2. Preparing to Publish

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

이 문서는 모바일 디바이스 사용자들에게 여러분의 안드로이드 애플리케이션을 배포하기 이전에 사인하는 것에 대한 정보를 제공한다.

Overview

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.

안드로이드 시스템은 설치된 모든 애플리케이션이 인증서를 사용해서 디지털적으로 사인될 것을 요구한다. 그 인증서의 개인 키private key는 애플리케이션의 개발자에 의해 보유된다. 시스템은 그 인증서를 사용자가 어떤 애플리케이션을 설치할 수 있는지를 제어하기 위해서라기 보다는, 애플리케이션의 제작자를 식별하고 애플리케이션들간의 신뢰 관계를 확립하기 위한 수단으로 사용한다. 인증서는 인증 당국authority에 의해 사인될 필요는 없다: 안드로이드 애플리케이션은 자체적으로 사인된 인증서 사용이 완전히 허용되며, 그렇게 하는 것이 일반적이다.

The important points to understand about signing Android applications are:

안드로이드 애플리케이션에 사인하는 것을 이해하는데 중요한 점은 다음과 같다.

  • All applications must be signed. The system will not install an application that is not signed.
  • You can use self-signed certificates to sign your applications. No certificate authority is needed.
  • 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.
  • 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.
  • You can use standard tools Keytool and Jarsigner to generate keys and sign your application .apk files.
  • Once you have signed the application, use the zipalign tool to optimize the final APK package.
  • 모든 애플리케이션은 사인되어야 한다. 시스템은 사인되지 않은 애플리케이션은 설치하지 않을 것이다.
  • 여러분은 애플리케이션에 사인하기 위해 자체적으로 사인된 인증서를 사용할 수 있다. 인증 당국은 필요하지 않다.
  • 여러분은 여러분의 애플리케이션을 사용자에게 배포할 준비가 되었을 때 여러분의 애플리케이션을 알맞은 개인 키로 사인해야 한다. 여러분은 SDK 툴tool에 의해 생성한 디폴트 키로 사인된 애플리케이션을 배포할 수 없다.
  • 시스템은 설치 시점에만 사인한 사람의 인증서 만료 날짜를 테스트한다. 사인된 애플리케이션의 인증서가 애플리케이션이 설치된 이후에 만료되더라도 애플리케이션은 정상적으로 동작할 것이다.
  • 여러분은 키를 생성하고 여러분의 애플리케이션 .apk 파일에 사인하기 위해서 Keytool, Jarsigner와 같은 표준 툴tool을 사용할 수 있다.
  • 일단 애플리케이션을 사인하면, 최종 APK 패키지를 최적화하기 위해 zipalign 툴tool을 사용하라.

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.

안드로이드 시스템은 적절하게 사인되지 않은 애플리케이션을 설치하거나 실행하지 않을 것이다. 이것은 실제 디바이스던 또는 에뮬레이터던 상관없이 안드로이드 시스템이 구동되는 어느 곳에서든 적용된다. 이러한 이유로, 여러분은 에뮬레이터나 디바이스에서 애플리케이션을 실행하거나 디버그하기 이전에 여러분의 애플리케이션에 대한 사인을 해야 한다.

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.

안드로이드 SDK 툴tool은 디버그할 때 여러분의 애플리케이션이 사인되게 하는 것을 지원한다. 이클립스의 ADT 플러그인과 Ant 빌드 툴tool 모두 디버그 모드debug mode와 릴리즈 모드release mode인 두 가지의 사인 모드signing mode를 제공한다.

  • 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.
  • When your application is ready for release, you must compile in release mode and then sign the .apk . There are two ways to do this:
    • Using Keytool and Jarsigner in the command-line. In this approach, you first compile your application to an unsigned .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.
    • 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.
  • 개발과 테스트를 하는 동안, 여러분은 디버그 모드에서 컴파일 할 수 있다. 디버그 모드에서 빌드 툴tool은 알려진 앨리어스alias와 패스워드로 키스토어keystore와 키key를 생성하기 위해 JDK에 포함되어 있는 Keytool 유틸리티를 사용한다. 그런 다음에 그 툴tool은 각각의 컴파일 시점에 .apk 애플리케이션 파일을 사인하기 위해 디버그 키를 사용한다. 패스워드가 알려져 있기 때문에 그 툴tool은 여러분이 컴파일할 때마다 keystore/key 패스워드를 입력하도록 하는 프롬프트prompt를 필요로 하지 않는다.
  • 여러분의 애플리케이션을 배포할 준비가 되었을 때, 여러분은 릴리즈 모드에서 컴파일해야 하며, 그런 다음에 여러분의 개인 키를 가지고 .apk 를 사인해야 한다. 이것을 하는 것에는 두 가지 방법이 있다.
    • 커맨드 라인command line에서 Keytool과 Jarsigner를 사용하는 것. 이 접근 방법에서, 여러분은 먼저 여러분의 애플리케이션을 사인되지 않은 .apk로 컴파일해야 한다. 그런 다음에 여러분은 .apk를 Jarsigner(또는 유사한 툴)를 사용해서 여러분의 개인 키로 수작업으로 사인해야 한다. 만약 여러분이 알맞은 개인 키를 이미 가지고 있지 않다면, 여러분 자신의 keystore/key를 생성하기 위해 수작업으로 Keytool을 실행하고 그런 다음에 Jarsigner를 사용해서 여러분의 애플리케이션을 사인할 수 있다.
    • ADT Export 위저드를 사용하는 것. 여러분이 ADT 플러그인을 설치한 이클립스Eclipse에서 개발하고 있다면, 여러분은 애플리케이션을 컴파일하고 필요하다면 개인 키를 생성하고 .apk를 사인하는 모든 것을 하나의 프로세스로 하기 위해 Export 위저드를 사용할 수 있다.

Once your application is signed, don't forget to run zipalign on the APK for additional optimization.

일단 여러분의 애플리케이션이 사인되면, 추가적인 최적화를 위해 APK에 zipalign을 실행하는 것을 잊지마라.

Signing Strategies

Some aspects of application signing may affect how you approach the development of your application, especially if you are planning to release multiple applications.

애플리케이션 사인의 어떤 측면은 여러분의 애플리케이션 개발에 접근하는 방법에 영향을 미칠 수도 있다. 특히 여러분이 여러 개의 애플리케이션을 릴리즈하려고 한다면 그럴 수 있다.

In general, the recommended strategy for all developers is to sign all of your applications with the same certificate, throughout the expected lifespan of your applications. There are several reasons why you should do so:

일반적으로 모든 개발자에게 권장하는 전략은 여러분의 애플리케이션의 전체 기대 수명 동안 동일한 인증서로 여러분의 모든 애플리케이션을 사인하는 것이다. 여러분이 그렇게 해야 하는 다음과 같은 몇 가지 이유가 있다.

  • Application upgrade As you release upgrades to your application, you will want to sign the upgrades with the same certificate, if you want users to upgrade seamlessly to the new version. When the system is installing an update to an application, if any of the certificates in the new version match any of the certificates in the old version, then the system allows the update. If you sign the version without using a matching certificate, you will also need to assign a different package name to the application in this case, the user installs the new version as a completely new application.
  • Application modularity The Android system allows applications that are signed by the same certificate to run in the same process, if the applications so requests, so that the system treats them as a single application. In this way you can deploy your application in modules, and users can update each of the modules independently if needed.
  • Code/data sharing through permissions The Android system provides signature-based permissions enforcement, so that an application can expose functionality to another application that is signed with a specified certificate. By signing multiple applications with the same certificate and using signature-based permissions checks, your applications can share code and data in a secure manner.
  • 애플리케이션 업그레이드 ? 여러분의 애플리케이션에 대한 업그레이드를 릴리즈할 때, 사용자가 새로운 버전을 일관되게 업그레이드 하기를 원한다면 여러분은 동일한 인증서로 업그레이드를 사인하고 싶어할 것이다. 시스템이 애플리케이션에 대한 업데이트를 설치할 때, 새로운 버전에 있는 임의의 인증서가 기존 버전 내의 있는 임의의 인증서와 일치한다면, 시스템은 업데이트를 허락한다. 만약 여러분이 일치하는 인증서를 사용하지 않고 새 버전을 사인한다면, 여러분은 또한 애플리케이션에 다른 패키지 이름을 지정하는 것이 필요할 것이다. 이 경우 사용자는 완전히 새로운 애플리케이션으로 새로운 버전을 인스톨한다.
  • 애플리케이션 모듈성 ? 동일한 인증서로 사인된 애플리케이션이 동일한 프로세스에서 실행되도록 그 애플리케이션들이 요구한다면, 안드로이드 시스템은 이를 허용하며, 애플리케이션들을 하나의 애플리케이션으로 취급한다. 이와 같은 방법에서 여러분은 애플리케이션을 모듈로 배치할 수 있고, 사용자는 필요할 때 각각의 모듈을 독립적으로 업데이트 할 수 있다.
  • 퍼미션을 통한 코드/데이터를 공유하기 ? 안드로이드 시스템은 시그니처signature 기반의 퍼미션 강제enforcement를 제공한다. 따라서 하나의 애플리케이션은 특정 인증서로 사인된 또 다른 애플리케이션에 기능을 제공할 수 있다. 동일한 인증서로 여러 개의 애플리케이션을 사인하고 시그니처signature 기반의 퍼미션 체크를 사용함으로써, 여러분의 애플리케이션들은 안전한 방법으로 코드와 데이터를 공유할 수 있다.

Another important consideration in determining your signing strategy is how to set the validity period of the key that you will use to sign your applications.

여러분의 사인 전략을 결정하는 데 있어서 또 다른 중요한 고려 사항은 여러분의 애플리케이션을 사인하기 위해 사용할 키의 유효 기간을 설정하는 방법이다.

  • If you plan to support upgrades for a single application, you should ensure that your key has a validity period that exceeds the expected lifespan of that application. A validity period of 25 years or more is recommended. When your key's validity period expires, users will no longer be able to seamlessly upgrade to new versions of your application.
  • If you will sign multiple distinct applications with the same key, you should ensure that your key's validity period exceeds the expected lifespan of all versions of all of the applications, including dependent applications that may be added to the suite in the future.
  • If you plan to publish your application(s) on Android Market, the key you use to sign the application(s) must have a validity period ending after 22 October 2033. The Market server enforces this requirement to ensure that users can seamlessly upgrade Market applications when new versions are available.
  • 만약 여러분이 하나의 애플리케이션에 대한 업그레이드를 지원할 계획이라면, 여러분의 키key가 애플리케이션의 기대 수명보다 긴 유효 기간을 가지도록 해야 한다. 25년이나 그 이상의 유효 기간이 권장된다. 여러분의 키key 유효 기간이 만료되면 사용자는 더이상 여러분의 새로운 애플리케이션 버전을 일관되게 업그레이드 할 수 없을 것이다.
  • 만약 여러분이 동일한 키key로 여러 개의 다른 애플리케이션을 사인할 것이라면, 여러분의 키key 유효기간을 미래에 그 애플리케이션 묶음에 추가될 수도 있는 종속된 애플리케이션을 포함하여 모든 애플리케이션의 모든 버전들의 수명보다 길게 해야 한다.
  • 만약 여러분의 애플리케이션(들)을 안드로이드 마켓에 배포할 계획이라면, 애플리케이션(들)을 사인하기 위해 여러분이 사용할 키key는 2033년 10월 22일 이후의 유효 기간을 가져야 한다. 안드로이드 마켓 서버는 새로운 버전을 사용할 수 있을 때 사용자가 안드로이드 마켓 서버 상의 애플리케이션을 일관되게 업그레이드할 수 있도록 이러한 요구 사항을 강제하고 있다.

As you design your application, keep these points in mind and make sure to use a suitable certificate to sign your applications.

여러분의 애플리케이션을 디자인할 때, 이러한 점을 기억하고 애플리케이션을 사인하기 위한 알맞은 인증서를 사용하도록 하라.

Basic Setup for Signing

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 JAVA_HOME environment variable to references a suitable JDK. Alternatively, you can add the JDK version of Keytool to your PATH variable.

키스토어Keystore와 디버그 키debug key 생성을 지원하기 위해, 여러분은 먼저 Keytool을 SDK 빌드 툴tool에서 사용가능한 지를 확인해야 한다. 대부분의 경우에, 여러분은 적합한 JDK를 레퍼런스하기 위해 여러분의 JAVA_HOME 환경 변수를 설정함으로써 SDK 빌드 툴tool이 Keytool을 찾는 방법을 알려줄 수 있다. 다른 방법으로는, 여러분의 PATH 변수에 Keytool의 JDK 버전을 추가할 수 있다.

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 be sure it points to the Keytool in the JDK.

만약 여러분이 처음부터 Java GNU 컴파일러Compiler를 보유하고 있는 리눅스 버전에서 개발하고 있다면, 시스템이 gcj 버전이 아니라 Keytool의 JDK 버전을 사용하는 것을 보장하라. 만약 Keytool이 이미 여러분의 PATH에 있다면, 그것은 /usr/bin/keytool에서 심볼릭 링크로 포인팅pointing되어 지고 있을 지 모른다. 이 경우, 그 심볼릭 링크의 타겟이 JDK에 있는 Keytool을 가리키도록 그 심볼릭 링크 타겟을 확인하라.

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.

만약 애플리케이션을 일반 대중에게 릴리즈할 것이라면, 여러분 머신machine에 사용가능한 Jarsigner 툴tool을 가질 필요가 있다. Jarsigner와 Keytool은 모두 JDK에 포함되어 있다.

Signing in Debug Mode

The Android build tools provide a debug signing mode that makes it easier for you to develop and debug your application, while still meeting the Android system requirement for signing your .apk. When using debug mode to build your app, the SDK tools invoke Keytool to automatically create a debug keystore and key. This debug key is then used to automatically sign the .apk, so you do not need to sign the package with your own key.

안드로이드 빌드 툴tool은 디버그 사인 모드를 제공한다. 이것은 여러분의 .apk를 사인하는 것에 대한 안드로이드 시스템 요구사항을 만족시키면서, 여러분이 애플리케이션을 좀 더 쉽게 개발하고 디버그할 수 있도록 한다. 여러분이 디버그 모드를 사용할 때, SDK 툴tool은 디버그 키스토어keystore와 키key를 생성하기 위해 Keytool을 부른다invoke. 이 디버그 키는 .apk를 자동으로 사인하기 위해 사용되어서, 여러분은 여러분 자신의 키로 패키지를 사인할 필요가 없다.

The SDK tools create the debug keystore/key with predetermined names/passwords:

SDK 도구는 미리 결정된 이름과 패스워드로 디버그 키스토어/키(keystore/key)를 생성한다.

  • Keystore name: "debug.keystore"
  • Keystore password: "android"
  • Key alias: "androiddebugkey"
  • Key password: "android"
  • CN: "CN=Android Debug,O=Android,C=US"
  • 키스토어Keystore 이름 - “debug.keystore”
  • 키스토어Keystore 패스워드 - “android”
  • 키Key 앨리어스 - “androiddebugkey”
  • 키Key 패스워드 - “android”
  • CN - “CN=Android Debug,O=Android,C=US”

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 keystore/key must use the same keystore/key names and passwords as the default debug key (as described above). (To do so in Eclipse/ADT, go to Windows > Preferences > Android > Build.)

필요하다면, 여러분은 디버그 키스토어/키keystore/key의 장소와 이름을 바꿀 수 있고, 또한 사용할 커스텀 디버그 키스토어/키keystore/key를 제공할 수 있다. 하지만 임의의 커스텀 키스토어/키keystore/key는 (위에서 설명한 대로) 디폴트 디버그 키와 동일한 키스토어/키keystore/key 이름과 패스워드를 사용해야 한다. (Eclipse/ADT에서 이를 수행하기 위해, 여러분은 Windows > Prefs > Android > Build를 사용할 수 있다.)

Caution: You cannot release your application to the public when signed with the debug certificate.

Caution: 애플리케이션이 디버그 인증서로 사인되어 있다면, 애플리케이션을 일반 대중에게 릴리즈 할 수 없음을 유의하라.

Eclipse Users

If you are developing in Eclipse/ADT (and have set up Keytool as described above in Basic Setup for Signing), signing in debug mode is enabled by default. When you run or debug your application, ADT signs the .apk with the debug certificate, runs zipalign on the package, then installs it on the selected emulator or connected device. No specific action on your part is needed, provided ADT has access to Keytool.

만약 여러분이 Eclipse/ADT에서 개발하고 있고 위에서 언급한 대로의 셋업 Keytool을 가지고 있다면, 디폴트로 디버그 모드로 사인하는 것이 활성화된다. 여러분의 애플리케이션을 실행하거나 디버그할 때, ADT는 디버그 인증서로 .apk를 사인하고 패키지에 대한 zipalign을 수행하고 에뮬레이터 또는 연결된 디바이스에 그것을 설치한다. Keytool에 대한 접근이 ADT에 제공된다면, 여러분 입장에서 필요한 액션은 없다.

Ant Users

If you are using Ant to build your .apk files, debug signing mode is enabled by using the debug option with the ant command (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. The script then also aligns the .apk with the zipalign tool. No other action on your part is needed. Read Developing In Other IDEs: Building in debug mode for more information.

만약 여러분이 .apk 파일을 빌드하기 위해 앤트Ant를 사용하고 있다면, 디버그 사인 모드는 ant 커맨드와 함께 debug 옵션을 사용함으로써 활성화된다. 여러분이 android 툴tool에 의해 생성된 build.xml 파일을 사용한다고 가정할 때 그렇다. 여러분의 애플리케이션을 컴파일하기 위해 ant debug를 실행할 때, build 스크립트는 여러분을 위해 키스토어/키keystore/key를 생성하고 .apk를 사인한다. 여러분 입장에서 필요한 액션은 없다. 더 많은 정보에 대해서는 Developing In Other IDEs: Building in debug mode(http://developer.android.com/guide/developing/other-ide.html#DebugMode)를 읽어라.

Expiry of the Debug Certificate

The self-signed certificate used to sign your application in debug mode (the default on Eclipse/ADT and Ant builds) will have an expiration date of 365 days from its creation date.

(디폴트로 이클립스/ADT와 Ant 빌드시) 디버그 모드에서 여러분의 애플리케이션을 사인하는 데 사용되는 자체 사인된self-signed 인증서는 그것이 생성된 날짜로부터 365일의 만료 일자를 가질 것이다.

When the certificate expires, you will get a build error. On Ant builds, the error looks like this:

그 인증서가 만료되면, 여러분은 빌드 에러를 얻을 것이다. 앤트Ant 빌드에서, 그 에러는 아래와 같이 보인다.

debug:
[echo] Packaging bin/samples-debug.apk, and signing it with a debug key...
[exec] Debug Certificate expired on 8/4/08 3:43 PM

In Eclipse/ADT, you will see a similar error in the Android console.

Eclipse/ADT에서, 여러분은 안드로이드 콘솔console에서 비슷한 에러를 보게 될 것이다.

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\\.android\ on Windows XP, and in C:\Users\\.android\ on Windows Vista.

이 문제를 해결하기 위해서는, 간단하게 debug.keystore 파일을 삭제하라. AVD들을 위한 디폴트 저장공간 위치는 Linux/Mac OS X에서는 ~/.android/avd 이며, Windows XP에서는 C:\Documents and Settings\<user>\.android\ 이고, Windows Vista에서는 C:\Users\<user>\.android\ 이다.

The next time you build, the build tools will regenerate a new keystore and debug key.

여러분이 다음에 빌드할 때, 빌드 도구는 신규 키스토어keystore와 디버그 키debug key를 생성할 것이다.

Note that, if your development machine is using a non-Gregorian locale, the build tools may erroneously generate an already-expired debug certificate, so that you get an error when trying to compile your application. For workaround information, see the troubleshooting topic Ican'tcompile my app because the build tools generated an expired debug certificate.

여러분이 개발할 때 사용하는 기계가 태양력이 아닌non-Gregorian 로케일locale을 사용하고 있다면, 빌드 툴tool은 잘못되어 이미 만료된 디버그 인증서를 생성할 지도 모른다. 그러므로 여러분의 애플리케이션을 컴파일할 때 에러를 얻는다. 이 문제를 회피하는 법에 대한 정보에 대해서 ‘I can’t compile my app because the build tools generated an expired debug certificate.’에 대한 아래의 URL 정보를 보라. http://developer.android.com/guide/appendix/faq/troubleshooting.html#signingcalendar

Signing for Public Release

When your application is ready for release to other users, you must:

여러분의 애플리케이션이 다른 사용자에게 릴리즈 할 준비가 되었을 때, 여러분은 다음과 같은 것을 해야 한다.

  1. Obtain a suitable private key
  2. Compile the application in release mode
  3. Sign your application with your private key
  4. Align the final APK package
  1. 적합한 개인 키 얻기
  2. 릴리즈 모드에서 애플리케이션 컴파일하기
  3. 개인 키private key로 애플리케이션 사인하기
  4. 최종 APK 패키지를 얼라인align 하기

If you are developing in Eclipse with the ADT plugin, you can use the Export Wizard to perform the compile, sign, and align procedures. The Export Wizard even allows you to generate a new keystore and private key in the process. So if you use Eclipse, you can skip to Compile and sign with Eclipse ADT.

만약 여러분이 ADT 플러그인을 가진 이클립스를 사용한다면, 여러분은 개인 키private key를 가지고 apk를 컴파일하고 사인하고 얼라인align하기 위해 Export 위저드를 대신 사용할 수 있다. 그 Export 위저드는 여러분으로 하여금 그 과정에서 새로운 키스토어keystore와 개인 키private key를 생성하는 것까지 가능하게 한다. 따라서 여러분이 이클립스를 사용한다면 “이클립스 ADT를 사용해서 컴파일하고 사인하기” 섹션으로 건너 뛰어라.

1. Obtain a suitable private key

In preparation for signing your application, you must first ensure that you have a suitable private key with which to sign. A suitable private key is one that:

여러분의 애플리케이션에 사인하는 것을 준비하면서, 여러분은 사인할 적합한 개인 키private key를 가지고 있는 지를 먼저 확인해야 한다. 적합한 개인 키private key는 아래와 같은 것이다.

  • Is in your possession
  • Represents the personal, corporate, or organizational entity to be identified with the application
  • Has a validity period that exceeds the expected lifespan of the application or application suite. A validity period of more than 25 years is recommended.

    If you plan to publish your application(s) on Android Market, note that a validity period ending after 22 October 2033 is a requirement. You can not upload an application if it is signed with a key whose validity expires before that date.

  • Is not the debug key generated by the Android SDK tools.
  • 여러분의 소유 하에 있어야 한다.
  • 그 애플리케이션에 관계된 개인, 기업, 또는 조직적 엔티티를 나타내야 한다.
  • 애플리케이션이나 애플리케이션 묶음에 기대되는 수명을 넘어서는 유효 기간을 가지고 있어야 하며, 유효기간은 25년 이상이 권장된다.

    만약 여러분이 안드로이드 마켓에 여러분의 애플리케이션을 배포할 계획이라면, 유효기간이 2033년 10월 22일 이후에 끝나야 한다는 것에 유의하라. 여러분은 그 이전에 끝나는 유효 기간을 가진 키key로 사인된 애플리케이션은 업로드 할 수가 없다.

  • 안드로이드 SDK 툴tool에 의해 생성된 디버그 키debug key가 아니어야 한다.

The key may be self-signed. If you do not have a suitable key, you must generate one using Keytool. Make sure that you have Keytool available, as described in Basic Setup.

그 키key는 자체적으로 사인될 수 있다. 여러분이 적합한 키key를 가지고 있지 않다면, Keytool을 사용해서 그것을 생성해야 한다. “사인을 위한 기본적 셋업” 섹션에서 설명된 대로, 여러분이 사용할 수 있는 Keytool을 가지고 있는지 확인하라.

To generate a self-signed key with Keytool, use the keytool command and pass any of the options listed below (and any others, as needed).

Keytool을 가지고 자체적으로 사인된 키key를 생성하기 위해서는, keytool 명령어를 사용해서 아래에 나열된 옵션들 중 어떤 것을 전달하라(필요하다면 다른것들도).

Warning: Keep your private key secure. 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 for both the keystore and key.

Warning: 여러분의 개인 키를 안전하게 유지하라. 여러분이 Keytool을 실행하기 전에, 여러분의 키key를 안전하게 보유하는 방법과 그렇게 하는 것이 여러분과 사용자들에게 중요한 이유를 알기 위해 “개인 키를 안전하게 하기” 섹션을 읽도록 하라. 특히, 여러분의 키key를 생성할 때 키스토어keystore와 키key에 강력한 패스워드를 선택해야만 한다.

Keytool Option Description
-genkey Generate a key pair (public and private keys)
-v Enable verbose output.
-keystore<keystore-name>.keystore A name for the keystore containing the private key.
-storepass <password>

A password for the keystore.

As a security precaution, do not include this option in your command line unless you are working at a secure computer. If not supplied, Keytool prompts you to enter the password. In this way, your password is not stored in your shell history.

-alias <alias_name> An alias for the key.
-keyalg <alg> The encryption algorithm to use when generating the key. Both DSA and RSA are supported.
-dname <name>

A Distinguished Name that describes who created the key. The value is used as the issuer and subject fields in the self-signed certificate.

Note that you do not need to specify this option in the command line. If not supplied, Jarsigner prompts you to enter each of the Distinguished Name fields (CN, OU, and so on).

-validity <valdays>

The validity period for the key, in days.

Note: A value of 10000 or greater is recommended.

-keypass <password>

The password for the key.

As a security precaution, do not include this option in your command line unless you are working at a secure computer. If not supplied, Keytool prompts you to enter the password. In this way, your password is not stored in your shell history.

Here's an example of a Keytool command that generates a private key:

여기에 개인 키private key를 생성하는 Keytool 명령어에 대한 예제가 있다.

$ keytool -genkey -v -keystore my-release-key.keystore 
-alias alias_name -keyalg RSA -validity 10000

Running the example command above, Keytool prompts you to provide passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. The keystore and key are protected by the passwords you entered. The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later, to refer to this keystore when signing your application.

위의 예제 명령어를 실행하면 Keytool은 여러분에게 키스토어keystore와 키key에 대한 패스워드를 입력하고 여러분의 키key를 구별하는 이름 필드를 입력하라고 프롬프트prompt를 보인다. 그리고 나서 키스토어keystore를 my-release-key.keystore로 불리는 파일로 생성한다. 키스토어Keystore와 키key는 여러분이 입력한 패스워드에 의해 보호된다. 키스토어Keystore는 10,000일 동안 유효한 하나의 키를 포함한다. 앨리어스alias는 여러분의 애플리케이션을 사인할 때, 키스토어keystore를 참조하기 위해 여러분이 나중에 사용할 이름이다.

For more information about Keytool, see the documentation at http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security

Keytool에 대한 더 많은 정보는http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security를 보라.

2. Compile the application in release mode

In order to release your application to users, you must compile it in release mode. In release mode, the compiled application is not signed by default and you will need to sign it with your private key.

여러분의 애플리케이션 릴리즈를 준비하기 위해, 여러분은 그것을 릴리즈 모드에서 컴파일 해야 한다. 릴리즈 모드에서, 컴파일된 애플리케이션은 디폴트로 사인되지 않으므로 여러분은 그것을 여러분의 개인 키로 사인할 필요가 있다.

Caution: You can not release your application unsigned, or signed with the debug key.

Caution: 여러분은 사인되지 않은 애플리케이션 또는 디버그 키debug key로 사인된 애플리케이션을 릴리즈 할 수 없다.

With Eclipse

To export an unsigned .apk from Eclipse, right-click the project in the Package Explorer and select Android Tools > Export Unsigned Application Package. Then 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.)

이클립스에서 사인되지 않은 .apk를 만들기 위해서는, Package Explorer의 프로젝트에서 마우스 우측 버튼을 클릭해서 Android Tools > Export Unsigned Application Package를 선택하라. 그런 다음에 사인되지 않은 .apk를 위한 파일 위치를 지정하라(다른 방법으로는, 이클립스에서 여러분의 AndroidManifest.xml 파일을 열고, Overview 탭을 열어서, Export an unsigned .apk 를 클릭하라).

Note that you can combine the compiling and signing steps with the Export Wizard. See Compiling and signing with Eclipse ADT.

여러분은 Export 위저드를 사용해서 컴파일과 사인 과정을 결합시킬 수 있다는 것에 주의하라. “이클립스 ADT를 사용해서 컴파일하고 사인하기” 섹션을 보라.

With Ant

If you are using Ant, you can enable release mode by using the release option with the ant command. For example, if you are running Ant from the directory containing your build.xml file, the command would look like this:

만약 여러분이 앤트Ant를 사용하고 있다면, 여러분은 ant 명령어에 release 옵션을 사용함으로써 릴리즈 모드를 활성화할 수 있다. 예를 들어 만약 여러분의 build.xml 파일을 포함하고 있는 디렉토리에서 Ant를 실행하고 있다면 명령어는 아래와 같이 보일 것이다.

ant release

By default, the build script compiles the application .apk without signing it. The output file in your project bin/ will be <your_project_name>-unsigned.apk. Because the application .apk is still unsigned, you must manually sign it with your private key and then align it using zipalign.

디폴트로, 빌드 스크립트는 애플리케이션 .apk를 사인하지 않고 빌드한다. 여러분의 프로젝트 bin/에 있는 출력파일은 <your_project_name>-unsigned.apk 일 것이다. 애플리케이션 .apk는 여전히 사인되어 있지 않기 때문에, 여러분은 그것을 여러분의 개인 키를 가지고 수작업으로 사인하고 zipalign을 이용하여 얼라인align해야 한다.

However, the Ant build script can also perform the signing and aligning for you, if you have provided the path to your keystore and the name of your key alias in the project's build.properties file. With this information provided, the build script will prompt you for your keystore and alias password when you perform ant release, it will sign the package and then align it. The final output file in bin/ will instead be <your_project_name>-release.apk. With these steps automated for you, you're able to skip the manual procedures below (steps 3 and 4). To learn how to specify your keystore and alias in the build.properties file, see Developing In Other IDEs: Building in release mode.

하지만, 여러분이 프로젝트의 build.properties 파일에 여러분의 키스토어/키 앨리어스의 경로를 제공한다면, Ant 빌드 스크립트는 또한 여러분을 위해 사인과 얼라인을 수행할 수 있다. 제공된 이 정보를 가지고, 여러분이 ant release 를 수행할 때 빌드 스크립트는 여러분의 키스토어와 앨리어스 패스워드를 입력하라고 프롬프트를 보일 것이다. 그리고 나서 빌드 스크립트는 패키지를 사인하고 얼라인할 것이다. bin/ 에 있는 최종 출력파일은 대신 <your_project_name>_release.apk 일 것이다. 여러분을 위한 자동화된 이 과정들을 사용하여, 여러분은 아래의 수작업 절차(과정 3, 4)를 건너 뛸 수 있다. build.properties 파일에 여러분의 키스토어와 앨리어스를 지정하는 방법을 알기 위해서는 아래의 URL에 있는 “Developing In Other IDEs: Building in release mode”를 보라. Developing In Other IDEs: Building in release mode.

3. Sign your application with your private key

When you have an application package that is ready to be signed, you can do sign it using the Jarsigner tool. Make sure that you have Jarsigner available on your machine, as described in Basic Setup. Also, make sure that the keystore containing your private key is available.

여러분이 실제 릴리즈를 위해 .apk 파일에 사인할 준비가 되었다면, 여러분은 Jarsigner 툴tool을 이용해서 그렇게 할 수 있다. “사인을 위한 기본적 셋업” 섹션에서 설명된 대로 여러분의 머신machine에 Jarsigner가 있는지 확인하라. 그리고 여러분의 개인 키private key를 가지고 있는 키스토어keystore가 유효한지도 확인하라.

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.

여러분의 애플리케이션을 사인 하기 위해서, 여러분은 애플리케이션의 .apk와 .apk를 사인할 개인 키private key를 가지고 있는 키스토어keystore 둘 모두를 레퍼런스하는 Jarsigner를 실행한다. 아래의 테이블은 여러분이 사용할 수 있는 옵션을 보여준다.

Jarsigner Option Description
-keystore<keystore-name>.keystore The name of the keystore containing your private key.
-verbose Enable verbose output.
-storepass <password>

The password for the keystore.

As a security precaution, do not include this option in your command line unless you are working at a secure computer. If not supplied, Jarsigner prompts you to enter the password. In this way, your password is not stored in your shell history.

-keypass <password>

The password for the private key.

As a security precaution, do not include this option in your command line unless you are working at a secure computer. If not supplied, Jarsigner prompts you to enter the password. In this way, your password is not stored in your shell history.

Here's how you would use Jarsigner to sign an application package called my_application.apk, using the example keystore created above.

여기에 위에서 생성한 예제 키스토어keystore를 사용하여 my_application.apk라고 불리는 애플리케이션 패키지에 사인하기 위한 Jarsigner 사용 방법이 있다.

$ jarsigner -verbose -keystore my-release-key.keystore 
my_application.apk alias_name

Running the example command above, Jarsigner prompts you to provide 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.

위의 예제 명령을 실행하면, Jarsigner가 여러분에게 키스토어keystore와 키key에 대한 패스워드를 입력하라고 한다. 그러면 그것은 .apk를 수정하며, 이는 .apk가 이제 사인되었다는 것을 의미한다. 여러분이 다른 키key로 .apk를 여러 번 사인할 수 있음에 유의하라.

To verify that your .apk is signed, you can use a command like this:

여러분의 .apk가 사인되었는 지를 확인하기 위해, 여러분은 아래와 같은 명령어을 사용할 수 있다.

$ jarsigner -verify my_signed.apk

If the .apk is signed properly, Jarsigner prints "jar verified". If you want more details, you can try one of these commands:

만약 .apk가 제대로 사인되었다면, Jarsigner는 “jar verfied”라고 출력한다. 더 자세한 정보를 원한다면 아래 명령어 중의 하나를 시도해 볼 수 있다.

$ jarsigner -verify -verbose my_application.apk

or

또는

$ jarsigner -verify -verbose -certs my_application.apk

The command above, with the -certs option added, will show you the "CN=" line that describes who created the key.

위의 명령어에 -certs 옵션이 추가되면, 여러분에게 누가 키key를 생성했는지를 설명하는 “CN=” 라인을 보여줄 것이다.

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.

Note: 만약 여러분이 “CN=Android Debug”를 보게 된다면, 이것은 .apk가 안드로이드 SDK가 생성한 디버그 키key로 사인되었음을 의미한다. 여러분의 애플리케이션을 릴리즈하고자 한다면, 디버그 키debyg key 대신 여러분의 개인 키private key로 사인해야만 한다.

For more information about Jarsigner, see the documentation at http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security

Jarsigner에 대한 더 많은 정보에 대해서 http://java.sun.com/j2se/1.5.0/docs/tooldocs/#security를 보라.

4. Align the final APK package

Once you have signed the .apk with your private key, run zipalign on the file. This tool ensures that all uncompressed data starts with a particular byte alignment, relative to the start of the file. Ensuring alignment at 4-byte boundaries provides a performance optimization when installed on a device. When aligned, the Android system is able to read files with mmap(), even if they contain binary data with alignment restrictions, rather than copying all of the data from the package. The benefit is a reduction in the amount of RAM consumed by the running application.

일단 여러분이 여러분의 개인 키로 .apk를 사인했다면, 그 파일에 대해서 zipalign을 수행하라. 이 도구는 모든 압축되지 않은 데이터가 그 파일의 시작으로부터 상대적으로 특정 바이트 얼라인먼트를 가지고 시작한다는 것을 보장한다. 4-바이트 경계에서 얼라인먼트를 보장하는 것은 패키지가 디바이스 상에 설치될 때 성능 최적화를 제공한다. 파일들이 얼라인먼트 제약을 가진 바이너리 데이터를 포함한다 할지라도 파일들이 얼라인될 때, 안드로이드 시스템은 패키지로부터 모든 데이터를 복사하기 보다는 mmap()을 사용해서 파일들을 읽을 수 있다.

The zipalign tool is provided with the Android SDK, inside the tools/ directory. To align your signed .apk, execute:

zipalign 도구는 Android SDK와 함께 제공되며, tools/ 디렉토리안에 위치해 있다. 여러분의 사인된 .apk를 얼라인하기 위해 아래를 수행하라.

zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk

The -v flag turns on verbose output (optional). 4 is the byte-alignment (don't use anything other than 4). The first file argument is your signed .apk (the input) and the second file is the destination .apk file (the output). If you're overriding an existing .apk, add the -f flag.

-v 플래그는 verbose 출력(선택사항임)을 활성화한다. 4는 바이트-얼라인먼트이다. (4가 아닌 값을 사용하지 마라) 첫번째 파일인자는 여러분의 사인된 .apk(입력)이고 두번째 파일인자는 최종 .apk 파일(출력)이다. 여러분이 이미 존재하는 .apk를 오버라이드할 것이라면, -f 플래그를 추가하라.

Caution: Your input .apk must be signed with your private key before you optimize the package with zipalign. If you sign it after using zipalign, it will undo the alignment.

Caution: 여러분은 zipalign을 사용해서 패키지를 최적화하기 전에 여러분의 입력 .apk는 여러분의 개인 키를 가지고 사인되어야 한다. 만약 여러분이 zipalign을 사용한 후 패키지를 사인한다면, 패키지는 얼라인먼트 이전 상태로 돌아갈 것이다.

For more information, read about the zipalign tool.

더 많은 정보에 대해서는 zipalign 툴을 읽어라.

Compile and sign with Eclipse ADT

If you are using Eclipse with the ADT plugin, 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 sign the package using a GUI instead of performing the manual procedures to compile, sign, and align, as discussed above. Once the wizard has compiled and signed your package, it will also perfom package alignment with zipalign. 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.

여러분이 ADT를 가진 이클립스를 사용한다면, 여러분은 사인된 .apk를 만들기 위해 Export 위저드를 사용할 수 있다(심지어 필요하다면 새로운 키스토어(keystore)를 생성할 수 있다). Export 위저드는 여러분을 위해 Keytool 및 Jarsigner와의 모든 상호작용을 수행한다. 이는 여러분으로 하여금 패키지를 컴파일하고 사인하고 얼라인하기 위해 수작업 절차를 수행하는 대신에 GUI를 이용하여 사인하도록 허용한다. 위저드가 일단 여러분의 패키지를 컴파일하고 사인하면, zipalign을 이용하여 패키지 얼라인먼트를 수행할 것이다. Export 위저드가 Keytool과 Jarsigner 모두를 사용하기 때문에, 여러분은 “사인을 위한 기본적 셋업”에서 위에 설명한 대로 여러분의 컴퓨터에서 그것들이 접근 가능하다는 것을 보장해야 한다.

To create a signed and aligned .apk in Eclipse:

이클립스에서 사인되고 얼라인된 .apk를 생성하기 위해,

  1. Select the project in the Package Explorer and select File > Export.
  2. Open the Android folder, select Export Android Application, and click Next.

    The Export Android Application wizard now starts, 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).

  3. Complete the Export Wizard and your application will be compiled, signed, aligned, and ready for distribution.
  1. Package Explorer에서 프로젝트를 선택하고 File > Export를 선택하라.
  2. 안드로이드 폴더를 열고, Export Android Application을 선택하고, Next를 클릭하라.

    Export Android Application 위저드는 이제 시작하며, 이것은 (새로운 키스토어와 개인 키 생성 또는) .apk를 사인하기 위해 개인 키를 선택하는 과정들을 포함하여 여러분의 애플리케이션을 사인하는 과정을 통해 여러분을 안내해 줄 것이다.

  3. Export 위저드를 종료하라. 그러면 여러분의 애플리케이션은 컴파일되고, 사인되고, 얼라인되고 배포할 준비가 되어 있을 것이다.

Securing Your Private Key

Maintaining the security of your private key is of critical importance, both to you and to the user. If you allow someone to use your key, or if you leave your keystore and passwords in an unsecured location such that a third-party could find and use them, your authoring identity and the trust of the user are compromised.

여러분의 개인 키private key에 대한 안전을 유지하는 것은, 여러분과 사용자 모두에게 매우 중요하다. 만약 여러분의 키key를 다른 사람이 사용할 수 있도록 여러분의 키스토어keystore와 패스워드를 안전하지 않은 장소에 놓아 두어 제3자가 찾아서 사용할 수 있게 한다면 여러분의 제작 신원authoring identity과 사용자의 신뢰 모두 훼손된다.

If a third party should manage to take your key without your knowledge or permission, that person could sign and distribute applications that maliciously replace your authentic applications or corrupt them. Such a person could also sign and distribute applications under your identity that attack other applications or the system itself, or corrupt or steal user data.

만약 여러분의 인지 또는 승인없이 제3자가 여러분의 키key를 가지게 된다면, 그 사람은 여러분의 원래 애플리케이션을 악의적으로 바꾸고 오류를 발생시키는 애플리케이션을 사인해서 배포할 수 있다. 그 사람은 또한 다른 애플리케이션이나 시스템을 공격하거나 사용자 데이터에 오류를 일으키거나 그것을 훔치는 애플리케이션을 여러분의 신원identity으로 사인해서 배포할 수도 있다.

Your reputation as a developer entity depends on your securing your private key properly, at all times, until the key is expired. Here are some tips for keeping your key secure:

개발자로서 여러분의 명성은 여러분의 개인 키private key가 만료될 때까지 그 키를 언제나 올바르게 안전하게 하는 지에 달려있다. 여기에 여러분의 키key를 안전하게 하는 몇 가지 팁이 있다.

  • Select strong passwords for the keystore and key.
  • When you generate your key with Keytool, do not supply the -storepass and -keypass options at the command line. If you do so, your passwords will be available in your shell history, which any user on your computer could access.
  • Similarly, when signing your applications with Jarsigner, do not supply the -storepass and -keypass options at the command line.
  • Do not give or lend anyone your private key, and do not let unauthorized persons know your keystore and key passwords.
  • 키스토어keystore와 키key에 대한 강력한 패스워드를 선택하라.
  • Keytool로 여러분의 키를 생성할 때, 커맨드 라인에 ?storepass, -keypass 옵션을 사용하지 마라. 만약 사용한다면 여러분의 패스워드는 shell history에 남아있게 되어 여러분 컴퓨터의 다른 사용자 누구라도 접근이 가능하게 된다.
  • 그와 비슷하게 Jarsigner로 애플리케이션을 사인할 때, 커맨드 라인에 ?storepass, -keypass 옵션을 사용하지 마라.
  • 여러분의 개인 키private key는 누구에게라도 주거나 빌려주지 말아라. 권한이 없는 사람들이 여러분의 키스토어keystore와 키 패스워드를 알게 하지 말아라.

In general, if you follow common-sense precautions when generating, using, and storing your key, it will remain secure.

일반적으로 여러분의 키key를 생성, 사용, 저장할 때, 상식 선의 주의사항들을 따른다면 키는 안전하게 유지될 것이다.

↑ Go to top