HowTo: Get an API Key from Google

Official Content
This documentation is valid for:

To use Google Maps in any compiled Android application, you must have an API Key from Google. If not, maps will not show when using the Maps Control Type or Geolocation domain.

Note: This is not required when prototyping the application through Knowledge Base Navigator, as it already has its own Maps API Key

By default, the generated app use a default Android debug-certificate to sign the application when compiling.
That allows you to install the application on devices,
directly with the *.apk file, but not through Google Play (as of GeneXus 15 U2), unless a custom certificate is created.

However, to use Google Maps service you need a special certificate called Map API Key, different from the previous one. This particular key is linked to the specific package name and the certificate mentioned before, in order to restrict the access. 

How can I get my API key?

This section explains how to obtain that key for your application.

1. Retrieve the fingerprint

The first thing to know is the fingerprint of the certificate that will sign the application (this is not required if while you are prototyping with the debug certificate provided by GeneXus).
To see this fingerprint run the following command, using the keystore provided by Android.

keytool -list -v -keystore <your_release_key.keystore> -alias <your_alias_name> -storepass <your_store_pass> -keypass <your_key_pass>

Where:

  Value Description Default (Android Application Signing)
  <your_release_key.keystore>   The filepath to the *.keystore file, whose value is set on Key Store File property C:\Users\<user>\.android\debug.keystore
  <your_alias_name> The alias of the *.keystore file, whose value is set on Key Alias property. androiddebugkey
  <your_store_pass> The key store password to access the *.keystore file, whose value is set on Store Password property.  android
  <your_key_pass> The key password to access a particular key pair's private key.  android


This command tool will print an output like this:

Alias name: androiddebugkey
Creation date: Dec 01, 2016
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: ********
Valid from: Mon Jan 01 08:04:04 UTC 2013 until: Mon Jan 01 18:04:04 PST 2033
Certificate fingerprints:
     MD5:  AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6A:AC:F9
     SHA1: 5F:BD:E1:6B:93:D6:5A:01:D2:C2:43:04:DD:2D:3D:93:A9:AD:C8:E8
     Signature algorithm name: SHA1withRSA
     Version: 3

The SHA1 value corresponds to the fingerprints.

Note: keytool program is installed on /bin directory of Java JDK 

2. Get the API Key

Go to Google API console and create a new API Key for your application.
The process to obtain that key can be done accessing to:

API Manager > Credentials > Create Credential > API Key.

Google APIs Console - Credentials section

3. Adding access restrictions 

The fingerprint of the step (1) allows adding exclusive access for this application. The following steps explain how to do it.

3.1 Select the API key

Click on the API Key created in step (2) from the list.
Google APIs Console - API Key list

3.2 Check Android apps

On Key restriction section, check for Android apps option.
Google APIs Console - Key restrictions

3.3 Add package/fingerprint

Click on "Add new package name and fingerprint" button, and complete the fields with your package name and fingerprint (from step (1))
Google APIs Console - Restrict usage section

3.4. Save your changes

4. Enabled Api

Depending the case, into the Google Apikey, is necessary enabled some Api,  such as: Geolocation Api and/or Directions Api and/or Maps Static API, etc
APIS_png

5. Set GeneXus's property

Finally, set the Android Maps API Key property with the value of Google API console (notice that there is not longer a warning icon).
Google APIs Console - API Keys list

Note

  • For those developers who has applications in production with the previous default settings (i.e. the *.apk file signed with Artech credentials) must generate the fingerprint with the legacy values.
    Value Default (Android Application Signing, as of GeneXus 15 Upgrade 3)
    <your_release_key.keystore>   C:\<GeneXus_Dir>\Android\legacy.keystore
    <your_alias_name> alias_name
    <your_store_pass> artech
    <your_key_pass> artech

See also