Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Google Maps API key for Android apps in debug mode

I've set the Google Maps API keys for Android in my tiapp.xml file:

ti.android.google.map.api.key.production
ti.android.google.map.api.key.development

For the production key, I followed the process for certificate/fingerprint on Google's site and generated an API key that works when I install the app from an .apk file generated from the "Distribute" tab in Titanium Developer.

I took the development key from the Kitchen Sink example app. It works fine from the Android Emulator, but when I install on an Android device from the "Run on Device" tab, the key doesn't work. I just get gray tiles on the map.

I guess taking the development key from Kitchen Sink isn't the best approach! What must I do to get a working API key in development mode?

Thanks.

— asked July 24th 2010 by Ryan McKillen
  • android
  • maps
0 Comments

6 Answers

  • Accepted Answer

    Hi, you need your own key
    go to android website enroll your key and use this configuration in your xml.

        <persistent-wifi>false</persistent-wifi>
        <prerendered-icon>false</prerendered-icon>
        <statusbar-style>default</statusbar-style>
        <statusbar-hidden>false</statusbar-hidden>
        <prerendered-icon>false</prerendered-icon>
        <fullscreen>false</fullscreen>
        <navbar-hidden>false</navbar-hidden>
        <analytics>true</analytics>
    <guid>GENERATED FROM YOUR APP</guid>
    <property name="ti.android.google.map.api.key">THE KEY U ISSUED</property>
    

    good luck
    Andrea

    — answered July 24th 2010 by Andrea S
    permalink
    3 Comments
    • I'm using my own API key in production, but it's my understanding that the keystore used to sign the app in debug mode is different, therefore a different API key is needed.

      — commented July 26th 2010 by Ryan McKillen
    • Added a ti.android.google.map.api.key property with the same key as my existing ti.android.google.map.api.key.production and it works.

      — commented July 28th 2010 by Ryan McKillen
    • Also of note: Titanium chokes on whitespace in this entry (and probably other property entries as well.

      <property name="ti.android.google.map.api.key">
          THE_KEY_U_ISSUED
      </property>
      

      Does NOT work!

      <property name="ti.android.google.map.api.key">THE_KEY_U_ISSUED</property>
      

      Does work

      — commented March 8th 2012 by Eric Rushing
  • Ahh… found the problem!! You need to have to have <code>

    <property name="ti.android.google.map.api.key.production">YOUR API KEY ISSUED HERE WITH NO SPACES</property>
    

    This worked for me. I hope this helps anyone else out there with the same problem :)

    — answered August 14th 2012 by Paulo Dichone
    permalink
    0 Comments
  • I am still having issue with this. After getting my api key from Google ( after going through the entire process )
    I am still getting a blank mapview with gray tiles on the map, but not the actual map. Anyone has any other suggestions, please?

    — answered August 14th 2012 by Paulo Dichone
    permalink
    1 Comment
    • I also having this problem. I'm sure I did everything right, but still cant get the Maps to work. Did you get it to work?

      — commented December 20th 2012 by Paul Merks
  • Make sure you have the internet permission set in the manifest file

    <uses-permission android:name="android.permission.INTERNET"/>
    

    Try that and let us know.

    — answered December 20th 2012 by Paulo Dichone
    permalink
    0 Comments
  • I am having the same issue. At first the screen goes black and then the map area appears with the zoom and current location controls. No tiles no images.
    I use the following tiap.xml. Anyone that knows what am i doing wrong.

    <?xml version="1.0" encoding="UTF-8"?>
    <ti:app xmlns:ti="http://ti.appcelerator.org">
        <id>com.three.pi.anatolia</id>
        <name>Anatolia</name>
        <version>1.0.7</version>
        <publisher>grezman</publisher>
        <url>http://anatolia.gr</url>
        <description>Anatolia Elementary School Communicator</description>
        <copyright>2013 by 3pi Information Systems</copyright>
        <icon>appicon.png</icon>
        <persistent-wifi>false</persistent-wifi>
        <prerendered-icon>false</prerendered-icon>
        <statusbar-style>OPAQUE_BLACK</statusbar-style> 
        <statusbar-hidden>false</statusbar-hidden>
        <fullscreen>false</fullscreen>
        <navbar-hidden>false</navbar-hidden>
        <analytics>false</analytics><!-- was true-->
        <guid>b30630a7-d321-41e5-80d2-ec4e27596177</guid>
        <property name="ti.ui.defaultunit" type="string">system</property>
        <property name="ti.android.bug2373.finishfalseroot" type="bool">true</property>
        <property name="ti.android.google.map.api.key">my production key here</property>
        <property name="ti.android.google.map.api.key.production">my production key here </property>
        <property name="ti.android.google.map.api.key.development">my debug key here</property>
        <iphone>
            <orientations device="iphone">
                <orientation>Ti.UI.PORTRAIT</orientation>
            </orientations>
            <orientations device="ipad">
                <orientation>Ti.UI.PORTRAIT</orientation>
                <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
                <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
                <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
            </orientations>
    
        </iphone>
        <property name="ti.android.fastdev" type="bool">false</property>
        <android xmlns:android="http://schemas.android.com/apk/res/android">
            <tool-api-level>14</tool-api-level>
            <manifest android:versionCode="1000007" android:versionName="1.0.7">
    
                <uses-permission android:name="android.permission.INTERNET"/>
                <!-- Allows the API to cache data -->
                <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
                <!-- Use GPS for device location -->
                <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
                <!-- Use Wi-Fi or mobile connection for device location -->
                <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
                <!-- Allows the API to access Google web-based services -->
                <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
                <!-- Specify OpenGL ES 2.0 as a requirement -->
                <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
                <!-- Replace <com.domain.appid> with your application ID -->
                <uses-permission android:name="com.three.pi.anatolia.permission.MAPS_RECEIVE" />
                <permission android:name="com.three.pi.anatolia.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
                <application>
                    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my production key here" />
                </application>
    
            </manifest>
        </android>
        <!-- Action Bar -->
        <mobileweb>
            <precache/>
            <splash>
                <enabled>true</enabled>
                <inline-css-images>true</inline-css-images>
            </splash>
            <theme>default</theme>
        </mobileweb>
        <modules>
            <module platform="android" version="0.2">net.iamyellow.gcmjs</module>
            <module platform="android">ti.map</module>
        </modules>
        <deployment-targets>
            <target device="android">true</target>
            <target device="blackberry">false</target>
            <target device="ipad">true</target>
            <target device="iphone">true</target>
            <target device="mobileweb">true</target>
            <target device="tizen">false</target>
        </deployment-targets>
        <sdk-version>3.1.3.GA</sdk-version>
        <plugins>
            <plugin version="1.0">ti.alloy</plugin>
        </plugins>
    </ti:app>
    
    — answered November 21st 2013 by Christos Gkrezios
    permalink
    0 Comments
  • Hi Christos,

    Just to make sure, did you check here. If not, you should most certainly take a look. Let me know if it helps.

    — answered November 21st 2013 by Paulo Dichone
    permalink
    1 Comment
    • Hi Paulo,
      thank you for your answer. I did checked on this link and this was my guideline to complete the process but still have the problem. I will now try to make a new app and make everything from the bottom up. I will be back with the results. I suspect the problem is in the certificate.

      — commented November 23rd 2013 by Christos Gkrezios
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.