Skip to content

Instantly share code, notes, and snippets.

@rynbyjn
Last active August 29, 2015 13:57
Show Gist options
  • Save rynbyjn/9813814 to your computer and use it in GitHub Desktop.
Save rynbyjn/9813814 to your computer and use it in GitHub Desktop.
Rake tasks for generating a SHA1 for use with the google maps API for Android.
# keystore vars
keystore = 'path_to_your.keystore'
keystore_alias = 'alias_for_your_keystore'
keystore_password = 'password_for_your_keystore'
namespace :android do
namespace :google do
namespace :maps do
desc 'Generates a debug SHA1 specific to your machine.'
task :debug_sha do
puts `keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android`
print_api_key_instructions
end
desc 'Lists aliases within the keystore file.'
task :list_aliases do
puts "password: #{keystore_password}"
puts `keytool -list -keystore #{keystore}`
end
desc 'Generates a release SHA1 specific to your machine.'
task :release_sha do
puts "password: #{keystore_password}"
puts `keytool -list -v -keystore #{keystore} -alias #{keystore_alias}`
print_api_key_instructions
end
end
end
end
def print_api_key_instructions
puts ''
puts '*** INSTRUCTIONS TO CREATE THE ACTUAL KEY ***'
puts 'Use the SHA1 to generate a google maps api key.'
puts 'Visit: https://console.developers.google.com'
puts 'Turn on: APIs & auth > APIs > Google Maps Android API v2'
puts 'Then: APIs & auth > Credentials > Create new key > Android Key'
puts 'Use the SHA1 with a semicolon and the package name at the end: SHA1;com.example.yourapp'
puts 'Add the generated API Key to the AndroidManifest.xml'
puts ''
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment