Step 3 of Android development: sign the certificate and install the compiler on the real machine

Source: Internet
Author: User

From: http://bbs.weiphone.com/read.php? Tid = 519993

Step 3 of Android development: sign the certificate and install the compiler on the real machine

The main change in Android SDK 1.6 is the debug signature Certificate automatically created by the simulator or real-machine available system (debug. keystore), but you must first create a self-signed certificate for the installable installer, including the keystore and private key alias.

There are two main methods for compiling and installing Android SDK: (a) using Apache ant (B) using Eclipse IDE.

(A) Apache ant

Windows Method

(1) create a self-signed certificate

Copy code

  1. Cd c:/Android/
  2. "C:/program files/Java/jdk1.6.0 _ 16/bin/keytool.exe"-genkey-v-keystore android-release-key.keystore-alias androidreleasekey-keyalg RSA -- validity 10000

Answer the following questions:

Copy code

  1. Enter keystore password: <-- set the keystore password-it must contain at least 6 Characters
  2. What is your first and last name?
  3. [UNKNOWN]: <-- enter your name
  4. What is the name of your organizational unit?
  5. [UNKNOWN]: <-- Organization Unit, which can be ignored.
  6. What is the name of your organization?
  7. [UNKNOWN]: <-- organization, which can be ignored.
  8. What is the name of your city or locality?
  9. [UNKNOWN]: <-- City
  10. What is the name of your state or province?
  11. [UNKNOWN]: <-- Province
  12. What is the two-letter country code for this unit?
  13. [UNKNOWN]: CN <-- Country
  14. Is Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = cn correct?
  15. [No]: Yes <-- enter yes to confirm
  16. Generating 1,024 bit RSA key pair and self-signed certificate (sha1withrsa) with a validity of 10,000 days
  17. For: Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = Cn
  18. Enter key password for <androidreleasekey>
  19. (Return if same as keystore password): <-- set the key password. If it is the same as the keystore password, press Enter.
  20. [Storing android-release-key.keystore]

(2) Go to command prompt and update notepad in Windows

Copy code

  1. Cd c:/Android/projects/Samples
  2. Android update project -- name notepad -- Target 2 -- path notepad

(3) create the build. properties file in the C:/Android/projects/samples/notepad directory. The content is as follows:

Copy code

  1. # This file is used to override default values used by the ant build system.
  2. #
  3. # This file must be checked in version control systems, as it is
  4. # Integral to the build system of your project.
  5. # The name of your application package as defined in the manifest.
  6. # Used by the 'uninstall' rule.
  7. Application-package = com. example. Android. notepad
  8. # The name of the source folder.
  9. # Source-Folder = SRC
  10. # The Name Of The Output Folder.
  11. # Out-Folder = Bin
  12. # You can also use it define how the release builds are signed by declaring
  13. # The following properties:
  14. # 'Key. store' for the location of your keystore and
  15. # 'Key. alias' for the name of the key to use.
  16. # The password will be asked during the build when you use the 'release' target.
  17. Key. Store = C:/Android/android-release-key.keystore
  18. Key. Alias = androidreleasekey

(4) You must first enable the USB debug mode on the mobile phone and execute it on the mobile phone.
Settings> Applications> development> USB debugging
Settings-> Applications-> development-> USB debugging

(5) connect the mobile phone to USB, check the device code and test the connection.

Copy code

  1. ADB Devices

If multiple devices are connected

Copy code

  1. List of devices attached
  2. Ht99xxx99999 Device
  3. Emulator-5554 Device

(6) code signature: Compile the notepad Project (this method only integrates the 1.6 Compilation Program, that is, the -- Target 2 option is used when the notepad project is updated at (2)

Copy code

  1. Cd c:/Android/projects/samples/notepad
  2. Ant release

The keystore password and key password are required.

Copy code

  1. [Input] Please enter keystore password (store: C: // Android/android-release-key.keystore ):
  2. Enter the keystore Password
  3. [Input] Please enter password for alias 'androidreleasekey ':
  4. Enter key password

(7) notepad installation on mobile phones
Method 1

Copy code

  1. Cd c:/Android/projects/samples/notepad
  2. Ant install

Method 2 (if multiple devices are connected)

Copy code

  1. Cd c:/Android/projects/samples/notepad
  2. ADB-s ht99xxx99999 install bin/NotePad-release.apk

Ht99xxx99999 is the device code found at (5 ).

(8) re-compile the program and install the notepad project on your mobile phone
Method 1

Copy code

  1. Cd c:/Android/projects/samples/notepad
  2. Ant install

Method 2 (if multiple devices are connected)

Copy code

  1. Cd c:/Android/projects/samples/notepad
  2. ADB-s ht99xxx99999 install-r bin/NotePad-release.apk

Ht99xxx99999 is the device code found at (5 ).

(9) If you need to delete the notepad project on your mobile phone
Method 1

Copy code

  1. Cd c:/Android/projects/samples/notepad
  2. Ant uninstall

Method 2 (if multiple devices are connected)

Copy code

  1. ADB-s ht99xxx99999 uninstall com. example. Android. notepad

Ht99xxx99999 is the device code found at (5 ).

Method 3: use mobile phone management programs such as APP manager or
Set-> application-> Manage application, select a program, and delete it.
Settings-> Applications-> Manage applications: select a program and delete it.

(10) The signature method for the above (6) point for the Compilation Program for 1.5 is as follows:

Use the -- Target 1 option when updating the lunarlander Project

Copy code

  1. Cd c:/Android/projects/Samples
  2. Android update project -- name lunarlander -- Target 1 -- path lunarlander

Compilation, signature, and alignment

Copy code

  1. Cd c:/Android/projects/samples/lunarlander
  2. Ant release
  3. & Quot; C:/program files/Java/jdk1.6.0 _ 16/bin/jarsigner & quot;-verbose-keystore C:/Android/android-release-key.keystore-storepass mypassword-keypass mypassword bin/LunarLander-unsigned.apk androidreleasekey
  4. Zipalign-V 4 bin/LunarLander-unsigned.apk bin/LunarLander-release.apk

Avoid password Residues in history

Copy code

  1. "C:/program files/Java/jdk1.6.0 _ 16/bin/jarsigner"-verbose-keystore C:/Android/android-release-key.keystore bin/LunarLander-unsigned.apk androidreleasekey

Installation Method 1

Copy code

  1. Cd c:/Android/projects/samples/lunarlander
  2. ADB install bin/LunarLander-release.apk

Installation Method 2 (if multiple devices are connected)

Copy code

  1. Cd c:/Android/projects/samples/lunarlander
  2. ADB-s ht99xxx99999 install bin/LunarLander-release.apk

Ht99xxx99999 is the device code found at (5 ).

MAC/Linux Method

(1) create a self-signed certificate

Copy code

  1. Cd ~ /Android
  2. Keytool-genkey-v-keystore android-release-key.keystore-alias androidreleasekey-keyalg RSA -- validity 10000

Answer the following questions:

Copy code

  1. Enter keystore password: <-- set the keystore password-it must contain at least 6 Characters
  2. What is your first and last name?
  3. [UNKNOWN]: <-- enter your name
  4. What is the name of your organizational unit?
  5. [UNKNOWN]: <-- Organization Unit, which can be ignored.
  6. What is the name of your organization?
  7. [UNKNOWN]: <-- organization, which can be ignored.
  8. What is the name of your city or locality?
  9. [UNKNOWN]: <-- City
  10. What is the name of your state or province?
  11. [UNKNOWN]: <-- Province
  12. What is the two-letter country code for this unit?
  13. [UNKNOWN]: CN <-- Country
  14. Is Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = cn correct?
  15. [No]: Yes <-- enter yes to confirm
  16. Generating 1,024 bit RSA key pair and self-signed certificate (sha1withrsa)
  17. For: Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = Cn
  18. Enter key password for <androidreleasekey>
  19. (Return if same as keystore password): <-- set the key password. If it is the same as the keystore password, press Enter.
  20. [Storing android-release-key.keystore]

(2) enter terminal and update the notepad Project

Copy code

  1. Cd ~ /Android/projects/Samples
  2. Android update project -- name notepad -- Target 2 -- path notepad

(3) In ~ Create the build. properties file in the/Android/projects/samples/notepad directory. The content is as follows:

Copy code

  1. # This file is used to override default values used by the ant build system.
  2. #
  3. # This file must be checked in version control systems, as it is
  4. # Integral to the build system of your project.
  5. # The name of your application package as defined in the manifest.
  6. # Used by the 'uninstall' rule.
  7. Application-package = com. example. Android. notepad
  8. # The name of the source folder.
  9. # Source-Folder = SRC
  10. # The Name Of The Output Folder.
  11. # Out-Folder = Bin
  12. # You can also use it define how the release builds are signed by declaring
  13. # The following properties:
  14. # 'Key. store' for the location of your keystore and
  15. # 'Key. alias' for the name of the key to use.
  16. # The password will be asked during the build when you use the 'release' target.
  17. # Linux
  18. # Key. Store =/home/ipod4g/Android/android-release-key.keystore
  19. # Mac
  20. Key. Store =/users/ipod4g/Android/android-release-key.keystore
  21. Key. Alias = androidreleasekey

(4) You must first enable the USB debug mode on the mobile phone and execute it on the mobile phone.
Settings> Applications> development> USB debugging
Settings-> Applications-> development-> USB debugging

(5) connect the mobile phone to USB, check the device code and test the connection.

Copy code

  1. ADB Devices

If multiple devices are connected

Copy code

  1. List of devices attached
  2. Ht99xxx99999 Device
  3. Emulator-5554 Device

(6) code signature: Compile the notepad Project (this method only integrates the 1.6 Compilation Program, that is, the -- Target 2 option is used when the notepad project is updated at (2)

Copy code

  1. Cd ~ /Android/projects/samples/notepad
  2. Ant release

The keystore password and key password are required.

Copy code

  1. [Input] Please enter keystore password (store:/users/ipod4g/Android/android-release-key.keystore ):
  2. Enter the keystore Password
  3. [Input] Please enter password for alias 'androidreleasekey ':
  4. Enter key password

(7) notepad installation on mobile phones
Method 1

Copy code

  1. Cd ~ /Android/projects/samples/notepad
  2. Ant install

Method 2 (if multiple devices are connected)

Copy code

  1. Cd ~ /Android/projects/samples/notepad
  2. ADB-s ht99xxx99999 install bin/NotePad-release.apk

Ht99xxx99999 is the device code found at (5 ).

(8) re-compile the program and install the notepad project on your mobile phone
Method 1

Copy code

  1. Cd ~ /Android/projects/samples/notepad
  2. Ant install

Method 2 (if multiple devices are connected)

Copy code

  1. Cd ~ /Android/projects/samples/notepad
  2. ADB-s ht99xxx99999 install-r bin/NotePad-release.apk

Ht99xxx99999 is the device code found at (5 ).

(9) If you need to delete the notepad project on your mobile phone
Method 1

Copy code

  1. Cd ~ /Android/projects/samples/notepad
  2. Ant uninstall

Method 2 (if multiple devices are connected)

Copy code

  1. ADB-s ht99xxx99999 uninstall com. example. Android. notepad

Ht99xxx99999 is the device code found at (5 ).

Method 3: use mobile phone management programs such as APP manager or
Set-> application-> Manage application, select a program, and delete it.
Settings-> Applications-> Manage applications: select a program and delete it.

(10) The signature method for the above (6) point for the Compilation Program for 1.5 is as follows:

Use the -- Target 1 option when updating the lunarlander Project

Copy code

  1. Cd ~ /Android/projects/Samples
  2. Android update project -- name lunarlander -- Target 1 -- path lunarlander

Compilation, signature, and alignment

Copy code

  1. Cd ~ /Android/projects/samples/lunarlander
  2. Ant release
  3. Jarsigner-verbose-keystore ~ /Android/android-release-key.keystore-storepass mypassword-keypass mypassword bin/LunarLander-unsigned.apk androidreleasekey
  4. Zipalign-V 4 bin/LunarLander-unsigned.apk bin/LunarLander-release.apk

Avoid password Residues in history

Copy code

  1. Jarsigner-verbose-keystore ~ /Android/android-release-key.keystore bin/LunarLander-unsigned.apk androidreleasekey

Installation Method 1

Copy code

  1. Cd ~ /Android/projects/samples/lunarlander
  2. ADB install bin/LunarLander-release.apk

Installation Method 2 (if multiple devices are connected)

Copy code

  1. Cd ~ /Android/projects/samples/lunarlander
  2. ADB-s ht99xxx99999 install bin/LunarLander-release.apk

Ht99xxx99999 is the device code found at (5 ).

(B) Eclipse IDE

(1) Select the program category in package explorer, and then select File> export...

(2) Open the android folder, select export Android Application, and click Next

(3) This will guide your application signing, this includes the steps for selecting and signing the keystore and key alias private key (or creating a new keystore and private key alias)

(4) After completion your application YourProgram-release.apk will be compiled (Compiled), signed (Signed), aligned (Aligned) and can be installed and released. For details about how to install or delete an application, refer to the above.
.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.