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
- Cd c:/Android/
- "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
- Enter keystore password: <-- set the keystore password-it must contain at least 6 Characters
- What is your first and last name?
- [UNKNOWN]: <-- enter your name
- What is the name of your organizational unit?
- [UNKNOWN]: <-- Organization Unit, which can be ignored.
- What is the name of your organization?
- [UNKNOWN]: <-- organization, which can be ignored.
- What is the name of your city or locality?
- [UNKNOWN]: <-- City
- What is the name of your state or province?
- [UNKNOWN]: <-- Province
- What is the two-letter country code for this unit?
- [UNKNOWN]: CN <-- Country
- Is Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = cn correct?
- [No]: Yes <-- enter yes to confirm
- Generating 1,024 bit RSA key pair and self-signed certificate (sha1withrsa) with a validity of 10,000 days
- For: Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = Cn
- Enter key password for <androidreleasekey>
- (Return if same as keystore password): <-- set the key password. If it is the same as the keystore password, press Enter.
- [Storing android-release-key.keystore]
|
(2) Go to command prompt and update notepad in Windows
Copy code
- Cd c:/Android/projects/Samples
- 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
- # This file is used to override default values used by the ant build system.
- #
- # This file must be checked in version control systems, as it is
- # Integral to the build system of your project.
- # The name of your application package as defined in the manifest.
- # Used by the 'uninstall' rule.
- Application-package = com. example. Android. notepad
- # The name of the source folder.
- # Source-Folder = SRC
- # The Name Of The Output Folder.
- # Out-Folder = Bin
- # You can also use it define how the release builds are signed by declaring
- # The following properties:
- # 'Key. store' for the location of your keystore and
- # 'Key. alias' for the name of the key to use.
- # The password will be asked during the build when you use the 'release' target.
- Key. Store = C:/Android/android-release-key.keystore
- 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.
If multiple devices are connected
Copy code
- List of devices attached
- Ht99xxx99999 Device
- 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
- Cd c:/Android/projects/samples/notepad
- Ant release
|
The keystore password and key password are required.
Copy code
- [Input] Please enter keystore password (store: C: // Android/android-release-key.keystore ):
- Enter the keystore Password
- [Input] Please enter password for alias 'androidreleasekey ':
- Enter key password
|
(7) notepad installation on mobile phones
Method 1
Copy code
- Cd c:/Android/projects/samples/notepad
- Ant install
|
Method 2 (if multiple devices are connected)
Copy code
- Cd c:/Android/projects/samples/notepad
- 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
- Cd c:/Android/projects/samples/notepad
- Ant install
|
Method 2 (if multiple devices are connected)
Copy code
- Cd c:/Android/projects/samples/notepad
- 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
- Cd c:/Android/projects/samples/notepad
- Ant uninstall
|
Method 2 (if multiple devices are connected)
Copy code
- 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
- Cd c:/Android/projects/Samples
- Android update project -- name lunarlander -- Target 1 -- path lunarlander
|
Compilation, signature, and alignment
Copy code
- Cd c:/Android/projects/samples/lunarlander
- Ant release
- & 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
- Zipalign-V 4 bin/LunarLander-unsigned.apk bin/LunarLander-release.apk
|
Avoid password Residues in history
Copy code
- "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
- Cd c:/Android/projects/samples/lunarlander
- ADB install bin/LunarLander-release.apk
|
Installation Method 2 (if multiple devices are connected)
Copy code
- Cd c:/Android/projects/samples/lunarlander
- 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
- Cd ~ /Android
- Keytool-genkey-v-keystore android-release-key.keystore-alias androidreleasekey-keyalg RSA -- validity 10000
|
Answer the following questions:
Copy code
- Enter keystore password: <-- set the keystore password-it must contain at least 6 Characters
- What is your first and last name?
- [UNKNOWN]: <-- enter your name
- What is the name of your organizational unit?
- [UNKNOWN]: <-- Organization Unit, which can be ignored.
- What is the name of your organization?
- [UNKNOWN]: <-- organization, which can be ignored.
- What is the name of your city or locality?
- [UNKNOWN]: <-- City
- What is the name of your state or province?
- [UNKNOWN]: <-- Province
- What is the two-letter country code for this unit?
- [UNKNOWN]: CN <-- Country
- Is Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = cn correct?
- [No]: Yes <-- enter yes to confirm
- Generating 1,024 bit RSA key pair and self-signed certificate (sha1withrsa)
- For: Cn = ipod4g, ou = unknown, O = unknown, L = unknown, St = unknown, c = Cn
- Enter key password for <androidreleasekey>
- (Return if same as keystore password): <-- set the key password. If it is the same as the keystore password, press Enter.
- [Storing android-release-key.keystore]
|
(2) enter terminal and update the notepad Project
Copy code
- Cd ~ /Android/projects/Samples
- 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
- # This file is used to override default values used by the ant build system.
- #
- # This file must be checked in version control systems, as it is
- # Integral to the build system of your project.
- # The name of your application package as defined in the manifest.
- # Used by the 'uninstall' rule.
- Application-package = com. example. Android. notepad
- # The name of the source folder.
- # Source-Folder = SRC
- # The Name Of The Output Folder.
- # Out-Folder = Bin
- # You can also use it define how the release builds are signed by declaring
- # The following properties:
- # 'Key. store' for the location of your keystore and
- # 'Key. alias' for the name of the key to use.
- # The password will be asked during the build when you use the 'release' target.
- # Linux
- # Key. Store =/home/ipod4g/Android/android-release-key.keystore
- # Mac
- Key. Store =/users/ipod4g/Android/android-release-key.keystore
- 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.
If multiple devices are connected
Copy code
- List of devices attached
- Ht99xxx99999 Device
- 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
- Cd ~ /Android/projects/samples/notepad
- Ant release
|
The keystore password and key password are required.
Copy code
- [Input] Please enter keystore password (store:/users/ipod4g/Android/android-release-key.keystore ):
- Enter the keystore Password
- [Input] Please enter password for alias 'androidreleasekey ':
- Enter key password
|
(7) notepad installation on mobile phones
Method 1
Copy code
- Cd ~ /Android/projects/samples/notepad
- Ant install
|
Method 2 (if multiple devices are connected)
Copy code
- Cd ~ /Android/projects/samples/notepad
- 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
- Cd ~ /Android/projects/samples/notepad
- Ant install
|
Method 2 (if multiple devices are connected)
Copy code
- Cd ~ /Android/projects/samples/notepad
- 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
- Cd ~ /Android/projects/samples/notepad
- Ant uninstall
|
Method 2 (if multiple devices are connected)
Copy code
- 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
- Cd ~ /Android/projects/Samples
- Android update project -- name lunarlander -- Target 1 -- path lunarlander
|
Compilation, signature, and alignment
Copy code
- Cd ~ /Android/projects/samples/lunarlander
- Ant release
- Jarsigner-verbose-keystore ~ /Android/android-release-key.keystore-storepass mypassword-keypass mypassword bin/LunarLander-unsigned.apk androidreleasekey
- Zipalign-V 4 bin/LunarLander-unsigned.apk bin/LunarLander-release.apk
|
Avoid password Residues in history
Copy code
- Jarsigner-verbose-keystore ~ /Android/android-release-key.keystore bin/LunarLander-unsigned.apk androidreleasekey
|
Installation Method 1
Copy code
- Cd ~ /Android/projects/samples/lunarlander
- ADB install bin/LunarLander-release.apk
|
Installation Method 2 (if multiple devices are connected)
Copy code
- Cd ~ /Android/projects/samples/lunarlander
- 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.
.