├── README.md └── key2debug /README.md: -------------------------------------------------------------------------------- 1 | # key2debug 2 | - - - - - - - - - - - - 3 | 4 | Introduction 5 | -------------------- 6 | 7 | key2debug is a small script used to transform any android keystore to debug 8 | one. Which can be imported as custom debug key in Eclipse. 9 | 10 | This is very usefull if you want to test your application agains keystore-dependent services during application development. 11 | This way developers can be 100% sure that things like Google Maps and similar will work. 12 | 13 | The script will __not__ overwrite the exiting keystore, it will create __new__ 14 | one, with .debug suffix. 15 | 16 | 17 | Requirements 18 | -------------------- 19 | 20 | * Any linux distribution. 21 | * Installed and available keytool (commes with android SDK) 22 | * You must also know 23 | * Passphrase of the key 24 | * Alias and its password 25 | 26 | 27 | Usage 28 | -------------------- 29 | 30 | #### With root access 31 | 1. Download the script to your /usr/bin folder 32 | 2. Type `chmod +x /usr/bin/key2debug` 33 | 3. Type `key2debug ` 34 | 4. When promprted, supply with passphrase, alias and its password 35 | 36 | 37 | #### Without root access 38 | 1. Download the script to your system 39 | 2. Type `chmod +x /path/to/key2debug` 40 | 3. Type `/path/to/key2debug ` 41 | 4. When promprted, supply with passphrase, alias and its password 42 | 43 | 44 | Applying custom debug keystore in eclipse 45 | -------------------- 46 | 1. Open eclipse 47 | 2. From the menu select Windows -> Prefenrences 48 | 3. From the left menu select Android -> Build 49 | 4. To the right of the __Custom debug keystore__ input field click on the__Browse__ button 50 | 5. Find the generated file and click OK 51 | 6. You are done, just close the window 52 | 53 | To remove custom debug keystore, simply select and delete the __Custom debug keystore__ input field 54 | 55 | Credits 56 | -------------------- 57 | Script has been written by the [Intellex](http://intellex.rs/en) team. 58 | -------------------------------------------------------------------------------- /key2debug: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # title : key2debug 4 | # description : Convert any Android keystore to a debug keystore. 5 | # author : Intellex 6 | # date : 20150902 7 | # version : 0.0.1 8 | # usage : key2debug 9 | #=============================================================================== 10 | 11 | 12 | # Definitions { 13 | 14 | # Colors 15 | RED=$(tput setaf 1) 16 | CLEAR=$(tput sgr0) 17 | 18 | #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ } 19 | 20 | 21 | # Macros { 22 | 23 | # Error handling 24 | ERROR() { 25 | echo "${RED}ERROR: $1${CLEAR}" >&2 26 | exit 2 27 | } 28 | 29 | #~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ } 30 | 31 | 32 | 33 | # Get the keystore 34 | KEYSTORE=$1 35 | 36 | # Validate keystore 37 | if [ "${KEYSTORE}" = "" ]; then 38 | echo; echo "Usage: keystore2debug "; echo "Script will generate additional keystore, it will NOT overwrite exiting one."; echo; 39 | exit 1; 40 | 41 | elif [ ! -f "${KEYSTORE}" ]; then 42 | ERROR "Unable to find supplied keystore" 43 | fi 44 | 45 | # Create a debug file 46 | DEBUG="${KEYSTORE}.debug" 47 | cp "${KEYSTORE}" "${DEBUG}" 48 | if [ ! $? -eq 0 ]; then 49 | ERROR "Unable to write to ${DEBUG}" 50 | fi 51 | 52 | # Read { 53 | 54 | # Passphrase 55 | printf "Original passphrase: "; 56 | read PASSPHRASE 57 | 58 | # Alias 59 | printf "Original alias: " 60 | read ALIAS 61 | 62 | # Alias password 63 | printf "Original alias password: " 64 | read PASSWORD 65 | 66 | # } 67 | 68 | # Change debug data 69 | 70 | # Set new passphrase to 'android' 71 | printf "${PASSPHRASE}\nandroid\nandroid" | keytool -storepasswd -keystore "${DEBUG}" >/dev/null 2>/dev/null 72 | if [ ! $? -eq 0 ]; then ERROR "Unable to unlock the keystore with supplied passphrase"; fi 73 | 74 | # Change the alias 75 | printf "android\n${PASSWORD}" | keytool -changealias -keystore ${DEBUG} -alias ${ALIAS} -destalias androiddebugkey >/dev/null 2>/dev/null 76 | if [ ! $? -eq 0 ]; then ERROR "Unable to unlock the keystore with supplied passphrase or bad alias"; fi 77 | 78 | # Set new password for alias 79 | printf "android\n${PASSWORD}\nandroid\nandroid" | keytool -keypasswd -keystore "${DEBUG}" -alias androiddebugkey >/dev/null 2>/dev/null 80 | if [ ! $? -eq 0 ]; then ERROR "Bad alias or alias password"; fi 81 | 82 | # Print message 83 | 84 | echo; echo "Success! Debug keystore saved as ${DEBUG}"; echo; 85 | --------------------------------------------------------------------------------