From 7f85bb12d2c3d14ee8721e93ddb6090a3000523b Mon Sep 17 00:00:00 2001
From: Andrew Solovay
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.
$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.
@@ -82,7 +82,8 @@ 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:
+
+
...
android {
...
@@ -103,12 +104,13 @@ android {
}
}
...
-
+
assembleRelease build task from Android Studio.The package in app/build/apk/app-release.apk is now signed with your release key.
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 @@ -156,17 +158,19 @@ For more information on packaging and signing Android Wear apps, see
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 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 +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.
+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.
@@ -193,14 +197,16 @@ Settings.
-Figure 4. Create a signing configuration in Android Studio.
+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.
+Figure 5. Select a signing configuration in Android +Studio.
Generate a private key using
- keytool.
+ keytool.
For example:
+$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000@@ -317,7 +324,7 @@ $ keytool -genkey -v -keystore my-release-key.keystoreSign your app with your private key using
-jarsigner:+$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name@@ -326,14 +333,14 @@ $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1
Verify that your APK is signed. For example:
-+$ jarsigner -verify -verbose -certs my_application.apk
Align the final APK package using
zipalign.
+$ zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk
zipalignensures that all uncompressed data starts with a particular byte