Android.PUA.DebugKey (Removal Guide)
Android.PUA.DebugKey is the detection name to threats detected by antivirus programs. This type of threat are malicious and can do unwanted actions into the device it infects.
Your antivirus software may have informed you of this threat because it had discovered the specific malware on your computer during the program’s routinely scans. These detections warnings should not be taken lightly since it means that your device is vulnerable and can be exploited by malicious actors.
You should take appropriate actions once the anti malware software notices these type of threats on your device. It is always best to get rid of it before it can do much harm to the computer.
These threats are often acquired through spam emails, infected websites, or by clicking on a link in an email. Once installed on the computer system, Android.PUA.DebugKey will begin to spread across your PC via Windows System files.
Hackers may be able to view all the data on your computer and even take over its operation once they have been deployed on the system. Threats like these should not be allowed to remain on the computer for an extended period of time because they may result in irreparable harm.
Users who have Android.PUA.DebugKey on their devices are most likely to face the following problems.
- Sudden issues with internet connection and applications
- Freezing or slowdowns in computer performance
- Difficulties opening documents or accessing files.
- Unusual popup-ads appearing online or when browsing.
- Overheat and high CPU usage.
These kinds of discoveries are particularly risky since they can be used to attack unsuspecting users online by stealing their financial information, privacy passwords, and other data.
It’s critical to get rid of this particular virus as soon as you suspect you may have been impacted by it. Typically the antivirus that has detected this threat should be enough to get rid of the said malware.
Unless certain circumstances prevent the anti malware program to eliminate the said malware, you may utilize Malwarebytes Anti Malware to help you remove the virus instead. You may follow the steps below to eliminate the threat that has been discovered from your system using Malwarebytes.
Remove Android.PUA.DebugKey with Malwarebytes
This program is one of the most effective anti-malware programs available. They have some of the greatest threat detection software, ensuring that any unwanted threats on your computer are totally eliminated.
You can utilize this antivirus program to complete the task since it was this program that detected the malicious threat. Furthermore, even if Android.PUA.DebugKey is completely removed from the computer, we recommend that you run a complete scan just in case.
1 Visit the antivirus website or click the button above to download the most up-to-date version of the software that best suits your requirements. For mobile devices, download the application from the Google Play Store or Apple App Store.

2 Follow the software installation instructions until they are completed.
3 Run a complete malware scan on the machine and wait for it to finish.

4 All the detected threats found on the computer will be shown on the screen and clicking the «quarantine» button to remove them.

Android.PUA.DebugKey, as well as any other harmful viruses discovered on the computer, should be eliminated once the process is complete. We also recommend to use Malwarebytes Real Time Protection, which will secure your machine and detect any threats as soon as they appear.
Alternative: Kaspersky Antivirus
There are instances where a different antivirus can find something another antivirus cannot. In this situation, if the first antivirus program didn’t work, we advise doing a scan with a different one.
If you visit numerous forums and websites, you will see most users agree that Kaspersky is one of the best antivirus tool available.

Since each antivirus application has its own threat database, Kaspersky’s detection technology may be able to find viruses that the prior program missed.
To ensure sure viruses are totally and undetectably removed from the system, we advise running a scan just in case. If you are downloading the application for the first time, you will also receive a 31-day premium trial.
1 Download the Kaspersky Security Cloud by clicking the button above.

2 Once the setup has finished downloaded, open the file and start the installation.

3 Wait until the wizard finds the latest version of the application or click Skip to install the current version stored.

4 Review the License Agreement. If you agree to its terms, click Continue.

5 Follow the installation instructions as shown then finally click install. (You may choose to uncheck the options shown if you do not want those features.)

6 Wait for the application to finish installing, then after the process is complete, click done.

7 Apply the recommended settings then start the application by clicking apply. Feel free to untick the options you do not desire.

8 You will be prompt to create an account and once you are finished, you will be redirected to the main screen. Select the Scan tab then click the run full scan and wait for it to complete. (Before scanning, we recommend you update the database to ensure any new malware variants are detected.)

After the scan has finished, the detected threats will be deleted from the computer. Reset the computer if prompted to do so.
What is Android.PUA.DebugKey? How to Fix it?
Have you recently downloaded an APK file from a third-party website? After downloading the file you may have scanned the file for malware on Virustotal. The scan results on VirusTotal may have detected an issue called Android.PUA.DebugKey. Now, you’re curious to know about Android.PUA.DebugKey.
In this article, I will explain Android.PUADebugKey in simple terms and also answer all of your questions related to it. I will also show you the methods to fix this issue and how to stay safe while using third-party sources to download APKs. So, let’s begin…
What is Android.PUA.DebugKey?
Android.PUA.DebugKey is a warning that comes up after scanning APK files on online scanners like VirusTotal. It means that the APK you downloaded is using the debug signature provided by Android Studio. The debug signature provided by Android Studio is only used for testing purposes. Android developers sign their APK files with their personal signature before releasing their apps on Google Play Store.
Now, if you download a MOD APK file from a third-party developer then they use the debug signature provided by Android Studio. These mod developers cannot access the original signature used by the developer of the app they modified. So, in this case, you’ll see an error something like this:

Is Android.PUA.DebugKey a virus?
Are you worried that Android.PUA.DebugKey can be a virus? Most of the time, it’s not. As you know that Android.PUA.DebugKey is caused by unmatched signatures and doesn’t relate to any malicious activity. So, most of the time when VirusTotal detects Android.PUA.DebugKey in an APK file is considered a false positive. However, I am not saying that it is completely safe to use apps. Android.PUA.DebugKey detection means that the app is being modified and a malicious actor may have inserted some malware in the app. I would suggest you look for another APK and only install it if you trust the developer.
Is Android.PUA.DebugKey safe?
As you’ve already understood the meaning of Android.PUA.DebugKey is not very harmful. Most of the time, VirusTotal detection of Android.PUA.DebugKey is a false positive. So, you can consider it safe and install apps if they are from a trusted developer. It is mostly detected in a modified version of APK where the original signature doesn’t match with the developer.
How to Fix Android.PUA.DebugKey?
If you want to fix Android.PUA.DebugKey issue, follow this tutorial:
- Download the APK file on your Windows or Linux PC
- Install JDK and apktool on your Windows or Linux PC
- Move downloaded APK to apktool folder
- Run apktool.jar to extract code from APK
- Edit the strings.xml and classes.dex file
- Replace the debug signature with the original signature(if you have one)
- Compile the Project and you fixed Android.PUA.DebugKey successfully
If you do not have a PC, you can use apktool on Termux or just install ApkTool M on your Android phone. In APKTool M, you get a GUI version or apktool.jar which doesn’t require you to install Java to decompile an APK. It comes with a code editor that helps you to edit code right in the app and compiler the project. After compiling the project, you’ll get the modified APK file with original signature that you’ve replaced.
Found this tutorial is helpful then please share it on social media and public forums like Reddit. You can ask your questions and give feedback in the comments section below. Follow us on Twitter and Telegram for the latest news and updates regarding Android and Google.
If you have any exclusive news tips for us then please share them with us through email at [email protected] You can also message me on Twitter for a quick conversation and send news tips.
Ключи Debug и их назначение
В Business Studio при работе осуществляется логирование. Объем логируемой информации может регулироваться с помощью ключей Debug, которые задаются для конкретного пользователя в его ветке реестра HKEY_CURRENT_USER\Software\STU-Soft\Business Studio <Номер версии Business Studio, в рамках которой требуется управлять логированием> в строковом параметре с именем Debug через запятую без пробелов.
Ключи Debug (или просто ключи) могут прописываться вручную или путём загрузки из файлов реестра, предоставляемых специалистами техподдержки.
Примечание: если Вы не являетесь администратором компьютера, для выполнения описанных действий может потребоваться ввод учетных данных. В этом случае необходимо вводить свои учетные данные, а не учетные данные системного администратора.
Инструкция по прописыванию ключей Debug путем загрузки из предоставляемых файлов реестра
Для прописывания ключей Debug путем загрузки из предоставляемых специалистами техподдержки файлов реестра следуйте приведённой ниже инструкции:
Чтобы внесенные изменения применились:
Ключи Debug для диагностики Business Studio Portal
Внимание! Если портал формируется под сервисом, то настройки логирования следует делать для того пользователя, под которым зарегистрирован сервис.
Ключи Debug, которые могут потребоваться для получения расширенных логов по процессу формирования и работы Business Studio Portal, приведены в таблице ниже.
| № | Описание ключа | Значение ключа Debug | Ссылка для скачивания архива с файлом для включения логирования с соответствующим ключом | |
|---|---|---|---|---|
| Для BS 4.2 | Для BS 5 | |||
| 1 | Подробно логируется содержимое пересылаемых пакетов. | On,Portal | Скачать | Скачать |
| 2 | Логируется описанное выше, а также подробно логируется процесс формирования каждого отчёта (данные по привязкам). | On,Portal,Report | Скачать | Скачать |
| 3 | Логируется описанное выше, а также логируются данные о времени начала и окончания формирования каждого отчёта. | On,Portal,Report,ReportStat | Скачать | Скачать |
| 4 | Отключение расширенного логирования (для экономии места на жёстком диске). | — (удалить параметр Debug) | Скачать | Скачать |
Чтобы работа портала начала логироваться с примененными ключами, требуется остановить его по кнопке "Остановить" в окне "Управление Business Studio portal Server" (см. Работа с Business Studio Portal Server) и снова запустить по кнопке "Запустить" в этом же окне.
Ключи Debug для диагностики HTML-публикации
Ключи Debug, которые могут потребоваться для получения расширенных логов по процессу формирования HTML -публикации, приведены в таблице ниже.
| № | Описание ключа | Значение ключа Debug | Ссылка для скачивания архива с файлом для включения логирования с соответствующим ключом | |
|---|---|---|---|---|
| Для BS 4.2 | Для BS 5 | |||
| 1 | Подробно логируется процесс формирования HTML -публикации. | On,Publication | Скачать | Скачать |
| 2 | Логируется описанное выше, а также подробно логируется процесс формирования каждого отчёта (данные по привязкам). | On,Publication,Report | Скачать | Скачать |
| 3 | Логируется описанное выше, а также логируются данные о времени начала и окончания формирования каждого отчёта. | On,Publication,Report,ReportStat | Скачать | Скачать |
| 4 | Отключение расширенного логирования (для экономии места на жёстком диске). | — (удалить параметр Debug) | Скачать | Скачать |
Для применения изменений в логировании необходимо перезапустить Business Studio.
Ключи Debug для диагностики процесса формирования отчётов
Ключи Debug, которые могут потребоваться для получения расширенных логов по процессу формирования отчётов, приведены в таблице ниже.
| № | Описание ключа | Значение ключа Debug | Ссылка для скачивания архива с файлом для включения логирования с соответствующим ключом | |
|---|---|---|---|---|
| Для BS 4.2 | Для BS 5 | |||
| 1 | Подробно логируется процесс формирования каждого отчёта (данные по привязкам). | On,Report | Скачать | Скачать |
| 2 | Логируется описанное выше, а также логируются данные о времени начала и окончания формирования каждого отчёта. | On,Report,ReportStat | Скачать | Скачать |
| 3 | Отключение расширенного логирования (для экономии места на жёстком диске). | — (удалить параметр Debug) | Скачать | Скачать |
Для применения изменений в логировании необходимо перезапустить Business Studio.
Ключи Debug для диагностики работы с диаграммами
Ключи Debug, которые могут потребоваться для получения расширенных логов по процессу формирования отчётов, приведены в таблице ниже.
| № | Описание ключа | Значение ключа Debug | Ссылка для скачивания архива с файлом для включения логирования с соответствующим ключом | |
|---|---|---|---|---|
| Для BS 4.2 | Для BS 5 | |||
| 1 | Подробно логируется процесс работы с диаграммой. | On,DiagramStat | Скачать | Скачать |
| 2 | Отключение расширенного логирования (для экономии места на жёстком диске). | — (удалить параметр Debug) | Скачать | Скачать |
Для применения изменений в логировании необходимо перезапустить Business Studio.
Что такое debug key
1.Whether the debug.keystore is used to generating the apk every time building the project normally?
2.I have done unzip the generated apk file. I came to see certificates are available in META-INF folder. Are these certificates generated with debug.keystore to identify the system identification?. Because, Both SHA1 hash values are same in debug.keystore and cert.RSA of unzipped apk.
Please clarify this doubt.
Thanks in advance..
2 Answers 2
Every apk that you want to install on your device needs to be signed. The debug key is just a random generated certificate by your build tools the first time you use it that is automatically used to sign when you build a debug build. It otherwise does not basically differ from a certificate that you generate for releasing in the play store (ommiting the fact that it uses wrong personal information and a fixed password, of course)
So again: if you build as debug the debug keystore is used, otherwise if you want to create a release you have to create your own keystore and point the build script to it.
In debug mode, you sign your app with a debug certificate generated by the Android SDK tools. This certificate has a private key with a known password, so you can run and debug your app without typing the password every time you make a change to your project.
Android Studio signs your app in debug mode automatically when you run or debug your project from the IDE.
You can run and debug an app signed in debug mode on the emulator and on devices connected to your development machine through USB, but you cannot distribute an app signed in debug mode.
By default, the debug configuration uses a debug keystore, with a known password and a default key with a known password. The debug keystore is located in $HOME/.android/debug.keystore, and is created if not present. The debug build type is set to use this debug SigningConfig automatically.
As a added pro tip: If you develop in a team with different shared test devices, it saves a lot of time if you all share the same debug keystore or else you always have to deinstall the debug app when getting the test device from another dev
Signing Your Applications
Android requires that all apps be digitally signed with a certificate before they can be installed. Android uses this certificate to identify the author of an app, and the certificate does not need to be signed by a certificate authority. Android apps often use self-signed certificates. The app developer holds the certificate’s private key.
Signing Overview
You can sign an app in debug or release mode. You sign your app in debug mode during development and in release mode when you are ready to distribute your app. The Android SDK generates a certificate to sign apps in debug mode. To sign apps in release mode, you need to generate your own certificate.
Signing in Debug Mode
In debug mode, you sign your app with a debug certificate generated by the Android SDK tools. This certificate has a private key with a known password, so you can run and debug your app without typing the password every time you make a change to your project.
Android Studio signs your app in debug mode automatically when you run or debug your project from the IDE.
You can run and debug an app signed in debug mode on the emulator and on devices connected to your development manchine through USB, but you cannot distribute an app signed in debug mode.
By default, the debug configuration uses a debug keystore, with a known password and a default key with a known password. The debug keystore is located in $HOME/.android/debug.keystore, and is created if not present. The debug build type is set to use this debug SigningConfig automatically.
For more information about how to build and run apps in debug mode, see Building and Running.
Signing in Release Mode
In release mode, you sign your app with your own certificate:
- Create a keystore. A keystore is a binary file that contains a set of private keys. You must keep your keystore in a safe and secure place.
- Create a private key. A private key represents the entity to be identified with the app, such as a person or a company.
Add the signing configuration to the build file for the app module:
The package in app/build/apk/app-release.apk is now signed with your release key.
Note: Including the passwords for your release key and keystore inside the build file is not a good security practice. Alternatively, you can configure the build file to obtain these passwords from environment variables or have the build process prompt you for these passwords.
To obtain these passwords from environment variables:
To have the build process prompt you for these passwords if you are invoking the build from the command line:
After you complete this process, you can distribute your app and publish it on Google Play.
Warning: Keep your keystore and private key in a safe and secure place, and ensure that you have secure backups of them. If you publish an app to Google Play and then lose the key with which you signed your app, you will not be able to publish any updates to your app, since you must always sign all versions of your app with the same key.
The rest of this document provides detailed instructions about how to generate a private key and sign your apps in release mode with Android Studio.
Signing Android Wear Apps
When publishing Android Wear apps, you package the wearable app inside of a handheld app, because users cannot browse and install apps directly on the wearable. Both apps must be signed. For more information on packaging and signing Android Wear apps, see Packaging Wearable Apps.
Signing Your App in Android Studio
To sign your app in release mode in Android Studio, follow these steps:
-
On the menu bar, click Build > Generate Signed APK.
On the Generate Signed APK Wizard window, click Create new to create a new keystore.
If you already have a keystore, go to step 4.
On the New Key Store window, provide the required information as shown in figure 1.
Your key should be valid for at least 25 years, so you can sign app updates with the same key through the lifespan of your app.

Figure 1. Create a new keystore in Android Studio.
On the Generate Signed APK Wizard window, select a keystore, a private key, and enter the passwords for both. Then click Next.

Figure 2. Select a private key in Android Studio.
On the next window, select a destination for the signed APK and click Finish.

Figure 3. Generate a signed APK in Android Studio.
Automatically Signing Your App
In Android Studio, you can configure your project to sign your release APK automatically during the build process:
- On the project browser, right click on your app and select Open Module Settings.
- On the Project Structure window, select your app’s module under Modules.
- Click on the Signing tab.
Select your keystore file, enter a name for this signing configuration (as you may create more than one), and enter the required information.

Figure 4. Create a signing configuration in Android Studio.
Under Signing Config, select the signing configuration you just created.

Figure 5. Select a signing configuration in Android Studio.
You can also specify your signing settings in Gradle configuration files. For more information, see Configuring Gradle Builds.
Signing Considerations
You should sign all of your apps with the same certificate throughout the expected lifespan of your applications. There are several reasons why you should do so:
- App upgrade: When the system is installing an update to an app, it compares the certificate(s) in the new version with those in the existing version. The system allows the update if the certificates match. If you sign the new version with a different certificate, you must assign a different package name to the application—in this case, the user installs the new version as a completely new application.
- App modularity: Android allows apps 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 app in modules, and users can update each of the modules independently.
- Code/data sharing through permissions: Android provides signature-based permissions enforcement, so that an app can expose functionality to another app that is signed with a specified certificate. By signing multiple apps with the same certificate and using signature-based permissions checks, your apps can share code and data in a secure manner.
If you plan to support upgrades for an app, ensure that your key has a validity period that exceeds the expected lifespan of that app. 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 plan to publish your apps on Google Play, the key you use to sign these apps must have a validity period ending after 22 October 2033. Google Play enforces this requirement to ensure that users can seamlessly upgrade apps when new versions are available.
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.
If a third party should manage to take your key without your knowledge or permission, that person could sign and distribute apps that maliciously replace your authentic apps or corrupt them. Such a person could also sign and distribute apps under your identity that attack other apps or the system itself, or corrupt or steal user data.
Your private key is required for signing all future versions of your app. If you lose or misplace your key, you will not be able to publish updates to your existing appn. You cannot regenerate a previously generated key.
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:
- Select strong passwords for the keystore and key.
- Do not give or lend anyone your private key, and do not let unauthorized persons know your keystore and key passwords.
- Keep the keystore file containing your private key in a safe, secure place.
In general, if you follow common-sense precautions when generating, using, and storing your key, it will remain secure.
Expiry of the Debug Certificate
The self-signed certificate used to sign your application in debug mode has an expiration date of 365 days from its creation date. When the certificate expires, you will get a build error.
To fix this problem, simply delete the debug.keystore file. The default storage location is in
/.android/ on OS X and Linux, in C:\Documents and Settings\<user>\.android\ on Windows XP, and in C:\Users\<user>\.android\ on Windows Vista and Windows 7.
The next time you build, the build tools will regenerate a new keystore and 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 I can’t compile my app because the build tools generated an expired debug certificate.
Signing Your App Manually
You do not need Android Studio to sign your app. You can sign your app from the command line using standard tools from the Android SDK and the JDK. To sign an app in release mode from the command line:
Generate a private key using keytool . For example:
This example prompts you for 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 contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app.
Compile your app in release mode to obtain an unsigned APK.
Sign your app with your private key using jarsigner :
This example prompts you for passwords for the keystore and key. It then modifies the APK in-place to sign it. Note that you can sign an APK multiple times with different keys.
Verify that your APK is signed. For example:
Align the final APK package using zipalign .
zipalign ensures that all uncompressed data starts with a particular byte alignment relative to the start of the file, which reduces the amount of RAM consumed by an app.
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 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.
The important points to understand about signing Android applications are:
- All applications must be signed. The system will not install an application on an emulator or a device if it is not signed.
- 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.
- 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.
- You can use self-signed certificates to sign your applications. No certificate authority is needed.
- 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.
- After you sign your application for release, we recommend that you use the zipalign tool to optimize the final APK package.
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 can run it or debug it on an emulator or device.
Signing Process
The Android build process signs your application differently depending on which build mode you use to build your application. There are two build modes: debug mode and release mode. 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 Google Play.
When you build in debug mode 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 .apk 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.
When you build in release mode 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 .apk 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.
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 debug 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 release option.
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 updates to your application, you will want to continue to sign the updates with the same certificate or set of certificates, if you want users to upgrade seamlessly to the new version. When the system is installing an update to an application, it compares the certificate(s) in the new version with those in the existing version. If the certificates match exactly, including both the certificate data and order, then the system allows the update. If you sign the new version without using matching certificates, 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.
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 Google Play, the key you use to sign the application(s) must have a validity period ending after 22 October 2033. Google Play enforces this requirement to ensure that users can seamlessly upgrade applications when new versions are available.
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, 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 JAVA_HOME environment variable so it references a suitable JDK. Alternatively, you can add the JDK version of Keytool and Jarsigner to your PATH variable.
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.
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.
The SDK tools create the debug keystore/key with predetermined names/passwords:
- Keystore name: «debug.keystore»
- Keystore password: «android»
- Key alias: «androiddebugkey»
- Key password: «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.)
Caution: You cannot release your application to the public when signed with the debug certificate.
Eclipse Users
If you are developing in Eclipse/ADT (and have set up Keytool and Jarsigner 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 file 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.
Ant Users
If you are using Ant to build your .apk file, 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 Building and Running Apps on the Command Line for more information.
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.
When the certificate expires, you will get a build error. On Ant builds, the error looks like this:
In Eclipse/ADT, you will see a similar error in the Android console.
To fix this problem, simply delete the debug.keystore file. The default storage location for AVDs is in
/.android/ on OS X and Linux, in C:\Documents and Settings\<user>\.android\ on Windows XP, and in C:\Users\<user>\.android\ on Windows Vista and Windows 7.
The next time you build, the build tools will regenerate a new keystore and 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 I can’t compile my app because the build tools generated an expired debug certificate.
Signing in Release Mode
When your application is ready for release to other users, you must:
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.
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:
- 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 Google Play, 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.
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.
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).
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.
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).
The password for the key.
As a security precaution, do not include this option in your command line. If not supplied, Keytool prompts you to enter the password. In this way, your password is not stored in your shell history.
The validity period for the key, in days.
Note: A value of 10000 or greater is recommended.
A password for the keystore.
As a security precaution, do not include this option in your command line. 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:
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.
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.
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, select the Manifest tab, and click 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.
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:
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 .
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 ant.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 ant.properties file, see Building and Running Apps on the Command Line.
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.
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.
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.
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.
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.
Caution: As of JDK 7, the default signing algorithim has changed, requiring you to specify the signature and digest algorithims ( -sigalg and -digestalg ) when you sign an APK.
To verify that your APK is signed, you can use a command like this:
If the APK is signed properly, Jarsigner prints «jar verified». 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 note»>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.
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.
The zipalign tool is provided with the Android SDK, inside the tools/ directory. To align your signed APK, execute:
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 file (the input) and the second file is the destination .apk file (the output). If you’re overriding an existing APK, add the -f flag.
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.
For more information, read about the zipalign tool.
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.
To create a signed and aligned APK in Eclipse:
- Select the project in the Package Explorer and select File > Export.
- 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).
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.
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.
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:
- 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.
In general, if you follow common-sense precautions when generating, using, and storing your key, it will remain secure.