Google maps in android gray grid - android

I'm trying to use mapviews in an app, so I followed the steps one by one. But I got just a gray grid. I generated the API key four times, but get the same result every time.
could you please help me?
These are the errors I got:
failed to find provider info for com.google.settings
couldn't get connection factory client
my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.test.g_maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="com.me.test.g_maps.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<permission
android:name="com.me.test.g_maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.me.test.g_maps.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCEgLQ7HgXiKTP8grZRmpIPAeWoSfAjrBM"/>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
my activity
package com.me.test.g_maps;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
my xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="#+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="AIzaSyCEgLQ7HgXiKTP8grZRmpIPAeWoSfAjrBM"
/>
</RelativeLayout>

As it looks you have few problems (in case your targeting Google Map API V2 technology)
1. First of all remove this permission:
<uses-library android:name="com.google.android.maps" />
It's a part of Google Maps API V1 and is not needed in Google Maps API V2.
2. Google Maps API V2 needs OpenGL-v2 support, and therefor you have to add the following to your manifest file:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
3. Check that you are turning on the right API in the Google API Console:
4. Try to regenerate the key again, by deleting the debug.keystore, compiling a project and that will result in a new SHA1 signature.
5. If you run your application in the emulator, check this blog post I wrote on how to enable Google Map API V2 in the emulator:
Google Map API V2 in the Emulator

If you are using Google api V1, you have to create a debug key to load correctly the map when you are debugging the app without signing it.
Else, you have to take a look here. New configuration on manifest is needed to use google maps api V2.

Replace com.google.android.maps.MapView with com.google.android.gms.maps.MapView. You are still using parts of Maps API V1. And it's better (easier) to use SupportMapFragment instead of MapView.
And don't use MapActivity either.

Related

Yet another Google Android Maps API v2 authentication issue

I had a working Google maps API v2 for Android example application that worked perfectly until I initialized a git repository in it's directory.
I have since then erased the entire project, all references to it in the Google cloud control, and started a new project.
The problem I'm facing now is an authentication issue:
11-07 10:44:05.445: E/Google Maps Android API(3640): Ensure that the following correspond to what is in the API Console: Package Name: [package name], API Key: [key], Certificate Fingerprint: [fingerprint]
I already tried with no avail:
1. Triple check API key and correct
2. Erase the entire project, disable Google maps API v2 for Android, enable it again and recreate the project
3. Add permissions for MAPS_RECEIVE
4. Cleaning, removing, and re-installing the release package
Really stumped by this one...
Here is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.mypackage"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.mycompany.mypackage.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.mycompany.mypackage.permission.MAPS_RECEIVE" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[My Key]" />
<activity
android:name="com.mycompany.canipark.MapExample"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And here is the code:
package com.mycompany.mypackage;
import com.mycompany.mypackage.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MapExample extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gmaps);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gmaps, menu);
return true;
}
}
And the layout:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:mapType="normal" />
And the Google cloud console:
http://i.stack.imgur.com/hSx9N.jpg
http://i.stack.imgur.com/8sNbm.jpg
ID of your package is com.mycompany.canipark, but in console com.mycompany
Also, try to write
<uses-library android:name="com.google.android.maps"/>
In AndroidManifest.xml in <application> section
I really don't understand this..
I waited two days, and suddenly everything's working again. I didn't change a single line of code.
Wish Google will add a meaningful error other than Authorization failure when it does...
Thanks guys for your help!

FragmentActivity showing blank map on device, what could be the reason behind that?

My problem is that the google maps is not showing on my android device 2.3.0
I am new in android and i am trying to use google map in my app, i have downloaded google play services, also have added adndroidsupportv4.jar, i have generated api key by using sha1, after completing all steps map not yet visible on device, what could be the problem behind that, can any one help me. Even i have dowloaded google play services emulator shows an error that google play services not installed, so what i have made mistake while developing google map application
My code is:
below is the MainActivity class
package com.example.androdemo;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
GoogleMap map;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map =((SupportMapFragment)
(getSupportFragmentManager().findFragmentById(R.id.map) )).getMap();
// map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
}
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.androdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.androdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.androdemo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB62caTnqcZoZil2lBc_qinUfNKNDmijRI"/>
</application>
</manifest>
i had the same issue, and the resolution was to generate a signed apk in order to view the map. i couldn't just view it on run or debug. had to be the signed application.
Another thing to check is that the internet is available on your android device.
I was developing an app that used google maps and they'd been working. I had no idea what was going on when suddenly they didn't appear. It turned out to be the lack of an internet connection that caused the problem!

Google Map not showing up in Android

1) It's showing empty map with grey color only with +(zoom in) and -(zoom out) buttons.
2) I extracted the SHA1 key from the debug.keystore and generated the MAP API V2 key in the
console.
3) I pasted that key in the manifest file.
4) GOOGLE MAP API V2 switched ON
and i use my Nexus 7 for debugging(USB Debugging)
LogCat Message :
Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network
errors).
Please help if i went somewhere wrong in these files.
AndoidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="metro.tailors"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />
<permission android:name="metro.tailors.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="metro.tailors.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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-feature android:glEsVersion="0x00020000" android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="metro.tailors.MainActivity"
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="metro.tailors.FactorsActivity"
android:label="#string/title_activity_factors" >
</activity>
<activity
android:name="metro.tailors.LadiesCategoryActivity"
android:label="#string/title_activity_ladies_category" >
</activity>
<activity
android:name="metro.tailors.GentsCategoryActivity"
android:label="#string/title_activity_gents_category" >
</activity>
<activity
android:name="metro.tailors.MapActivity"
android:label="#string/title_activity_map" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA2pMJiaPfwlz2yKaRNMZHykQkY_******"/>
</application>
</manifest>
This the XML File of the MapActivity
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
MapActivity.java
package metro.tailors;
import android.os.Bundle;
import android.app.Activity;
public class MapActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
}
}
4) GOOGLE MAP API V2 switched ON
You should turn on Google Maps for Android:
Fragment support start only from API > 11, So either change your manifest file to that or add android-support Library and use the SupportMapFragment object along side with FragmentActivity.
To download support library check the below link.
http://developer.android.com/tools/extras/support-library.html#Downloading
The doc states Use MapFragment class only if you are targeting API 12 and above. Otherwise, use SupportMapFragment.
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment.
regarding:
2) I extracted the SHA1 key from the debug.keystore and generated the MAP API V2 key in the console.
Not only do you have to do this, you also have to add your app to the list of allowed apps in the Google API Console, with your debug key and package name, as well as with your production keystore key and package name

Google maps v2 uthorization failure, could not contact google server

I trying to build a simple pedestrian dead reckoniing app using google map v2. But always got error 'Authorization failure' and 'could not contact google server'. I already check the api key, enable the 'Google Maps Android v2' service in Google API console, and allow my apps to use the API. but still not work.
Here's my manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pdr"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission
android:name="com.example.pdr.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.pdr.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.pdr.MainActivity"
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="com.example.pdr.MapActivity"></activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCu0QDFkPWOOAr0PACX2AUSSGkPWYmdpr0"/>
</application>
</manifest>
Here's the activity that using the map
public class MapActivity extends FragmentActivity {
private MapView map = null;
private GoogleMap gMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menu);
setUpMapIfNeeded();
};
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
if (gMap == null) {
gMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
}
}
private void setUpMap() {
gMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
And finally, here's the layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MapActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
Can anybody please help me ? I've been struggling for days..
Thanks in advance, and sorry for my english...
This problem is related to your api-key generation process. Please follow below mentioned steps to generate key-
1. generate SHA-1 using keytool.
2. open google console on browser, dont forget to enable Google Maps Android API v2 from sevices, now go on API Access, click on create new Android key, paste your SHA-1 along with semi-colon and your project package name then click on create,
3. copy the new API-key and paste in your manifest.
4. Most important, dont forget to import google play service lib from extras folder of sdk if already installed, Otherwise go to Android sdk-manager -> extras->google play service, make it installed then import from your sdk location->extras->google-> google play service.
5. Now add this lib to your working project.
This is the whole process to execute google maps android v2.
Now you can run your project, cheers......

Google Maps APIv2: Failed to find provider info for com.google.settings. Api key and internet permission are set

I want to display Google Map APIv2 in an emulator.
It seems to me that I've done everything according to official Google tutorial and this tutorial. I see "+" and "-" buttons to adjust zoom, but don't see the map.
I've tried to regenerate keystore and provide another api key, but this had no effect. The only guess I have is that eclipse signs my application with a debug key, though I've done export procedure from my keystore.
Or may be it's somehow jdk issue? I have jdk 1.7 installed, and android uses 1.6
Here are the errors that I get:
E/Trace(681): error opening trace file: No such file or directory (2)
E/ActivityThread(681): Failed to find provider info for com.google.settings
E/ActivityThread(681): Failed to find provider info for com.google.settings
E/ActivityThread(681): Failed to find provider info for com.google.android.gsf.gservices
E/ActivityThread(681): Failed to find provider info for com.google.android.gsf.gservices
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="us.irz.findme"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<permission
android:name="us.irz.findme.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="us.irz.findme.permission.MAPS_RECEIVE"/>
<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.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="us.irz.findme.LoginActivity"
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="us.irz.findme.DeviceActivity"></activity>
<activity android:name="us.irz.findme.MapActivity"></activity>
<activity android:name="us.irz.findme.TabsActivity"></activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_api_key"/>
</application>
</manifest>
map.xml file
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
MainActivity.java
public class MainActivity extends FragmentActivity implements OnClickListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
}
...
}
If you like to try it in a emulator, the emulator has to be created as with target Google Api level xx, not with Android 2.3 (for example), Sometimes the emulator can't load the map, so I recomended you to use a real Android device, your phone, tablet or something like this... Too check that the api key is the correct.. If you know spanish, can follow this tuto, is very good http://www.sgoliver.net/blog/?page_id=3011, search the section "Mapas en Android (Google Maps Android API v2) – I"...
Please check that you added the Google Play Services library in you project.

Categories

Resources