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.
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 -
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 :)
-
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? -
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.
-
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>
-
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.