csf
csf

Reputation: 1011

Map only appear in debug mode

My map appears only in debug mode, when I install the app on other devices not appear the map. I researched about it and realized that I have a key to debug and one for production. I do not know how to do this, google console can only have an api key for android apps. This is my Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="app.akexorcist.googlemapsv2direction.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <permission 
        android:name="app.akexorcist.googlemapsv2direction.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>

    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher_app"
        android:label="@string/app_name"  >
        <activity
            android:name="mypackage.Main"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".Search" ></activity>

        <meta-data
           android:name="com.google.android.maps.v2.API_KEY"
           android:value="myapykey" />      
    </application>
</manifest>

Upvotes: 0

Views: 249

Answers (2)

mjstam
mjstam

Reputation: 1079

Your map key is associated with a signing key.

Your debug application is likely signed with one key and your production application with another.

If that is true, you need to have two map keys in your application , one for debug and one for production. So you create two map keys in the API Console ( one for each signing key ).

Put both keys in your Manifest, but comment out the one your are not using, So just before shipping comment out the debug map key and uncomment the production one.

Make sure you check the production APK before shipping :) Hate to have a product with no map.

Upvotes: 0

Chris K.
Chris K.

Reputation: 987

Read this: https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key there is a step by tutorial how to use Maps API v2

Upvotes: 1

Related Questions