Google Map Load Issue - android

I am working on integrating google maps in a small app. My AndroidManifest.xml is
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mymaps"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.example.mymaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<uses-permission
android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <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" /> 
    <!-- Required to show current location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 
    <!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature android:glEsVersion="0x00020000"/>
<uses-feature 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.mymaps.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="MyKey" />
</application>
</manifest>
And my Main Activity is
public class MainActivity extends Activity implements OnClickListener {
TextView lat,lng;
Button getCds,getMap;
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeVars();
}
private void initializeVars() {
// TODO Auto-generated method stub
getCds = (Button)findViewById(R.id.bGC);
getMap = (Button)findViewById(R.id.bGM);
lat = (TextView)findViewById(R.id.TextView2);
lng = (TextView)findViewById(R.id.TextView4);
getCds.setOnClickListener(this);
getMap.setOnClickListener(this);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
public void onClick(View v) {
Log.d("Debugging", "I am in onCLick");
switch (v.getId()) {
case R.id.bGC:
{
Log.d("Debugging", "I am in case R.id.bGC");
lat.setText("My Lat");
lng.setText("My Long");
break;
}
case R.id.bGM:
{
Log.d("Debugging", "I am in case R.id.bGM");
lat.setText("blank");
lng.setText("blank");
break;
}
}
}
}
When I Load the application I am getting the below error.
01-17 14:01:49.054: E/Google Maps Android API(2832): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-17 14:01:49.064: E/Google Maps Android API(2832): Ensure that the following correspond to what is in the API Console: Package Name: com.example.mymaps, API Key: MyKey, Certificate Fingerprint: SomeValue
01-17 14:01:49.064: I/Google Maps Android API(2832): Failed to contact Google servers. Another attempt will be made when connectivity is established.
01-17 14:01:59.234: D/dalvikvm(2832): GC_CONCURRENT freed 572K, 9% free 7576K/8263K, paused 6ms+3ms
01-17 14:02:04.304: E/Google Maps Android API(2832): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
Guys to give a little more perspective. The same code used to work before (probably 3-4 months back). It somehow doesn't seem to be working anymore. I am not sure what is causing the same.
Can you please advise how to debug the same?

have a change from
<uses-permission
android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />
to
<uses-permission
android:name="com.example.mymaps.permission.MAPS_RECEIVE" />
I think the problem is with the key and it is not the correct one which you are using, Your API key in your manifest clearly does not match the API key you posted that is showing in the API console. Paste the API key from the console into the manifest. Should fix you right up.
you can uninstall the app, and do a project clean, then re-install the app.. have a try with this but still it does not works than
for more
please visit for the complete process for using new google map
http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/
http://www.learn2crack.com/2013/12/android-google-maps-api-v2-example.html
The best tutorial is
http://codebybrian.com/2012/12/06/google_maps_android_v2_sample.html

The your.package.name.permission.MAPS_RECEIVE is no longer needed. Please remove it from your manifest. Also you are missing this:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
It should be added within the <application> tag.

Related

Google map android studio leaked service connection

I am doing a simple app that has to do with maps in Android studio. When I run it with the release key,
keytool -list -v -keystore C:\Users\Theodosios\maps.jks -alias mapsalias -storepass
larissa -keypass larissa
the map doesn't run correctly. If I use the debug.kestore though everything works fine.The message in the output is
01-06 00:17:00.904: E/ActivityThread(1665):
Service com.google.android.gms.backup.BackupTransportService has leaked
ServiceConnection com.google.android.gms.http.f#3c9e1e50
that was originally bound here.
01-06 00:17:00.904: E/ActivityThread(1665):
android.app.ServiceConnectionLeaked: Service
com.google.android.gms.backup.BackupTransportService has leaked ServiceConnection
com.google.android.gms.http.f#3c9e1e50
that was originally bound here
01-06 00:17:00.904: E/ActivityThread(1665): at
android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:966)
01-06 00:17:00.904:
E/ActivityThread(1665):
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1768)
I took the code code of the MainActivity from google.It's pretty straight forward.
public class MainActivity extends ActionBarActivity {
GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createMapView();
addMarker();
}
/**
* Initialises the mapview
*/
private void createMapView(){
/**
* Catch the null pointer exception that
* may be thrown when initialising the map
*/
try {
if(null == googleMap){
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.mapView)).getMap();
/**
* If the map is still null after attempted initialisation,
* show an error to the user
*/
if(null == googleMap) {
Toast.makeText(getApplicationContext(),
"Error creating map", Toast.LENGTH_SHORT).show();
}
}
} catch (NullPointerException exception){
Log.e("mapApp", exception.toString());
}
}
private void addMarker(){
/** Make sure that the map has been initialised **/
if(null != googleMap){
Marker marker1= googleMap.addMarker(new MarkerOptions()
.position(new LatLng(39.648141,22.413155))
.title("Marker")
.draggable(true)
);
}
}
}
In the manifest file I add the necessary permissions.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="map.example.com.myapplication" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY KEY FROM GOOLE API CONSOLE GOES HERE" />
</application>
</manifest>

My Android Google Map can't load with all setup being accomplished, please check it out

I have check all settings, but it can't load the map with fragment but a zoom widget. It have no gridding. I have check the key but don't think it has any problem.
Below is my code.
manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17"/>
<!-- TODO: Replace "com.example.hellomap" with your package name -->
<permission
android:name="com.example.hellomap.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.hellomap.permission.MAPS_RECEIVE"/>
<!-- The following four permissions -->
<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:label="#string/app_name"
android:icon="#drawable/ic_launcher">
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDQFrrAorDIMec2q4kcxO9Y4hanG8x1YI0"/>
<activity
android:name="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>
</application>
</manifest>
layout:
<TextView
android:id="#+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tv_location"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
code:
package com.example.hellomap;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends FragmentActivity implements InfoWindowAdapter{
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setUpMapIfNeeded();
}
#Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
#Override
public View getInfoContents(Marker arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public View getInfoWindow(Marker arg0) {
// TODO Auto-generated method stub
return null;
}
}
Make sure that you have activated android map v2 api on google console.
you have created proper android key by entering correct SHA1 and package name on google console.
try to run it on physical device.
Make sure you have "Google Repository" installed from the SDK manager. They never mention this in the instructions but this must be installed alongside the Google Play Services SDK for everything to function.
Because I'm in China, it's not convenient to access Google server. Therefore I used a proxy to make the network can access the Google and then everything goes well. Thank all you guys for responding and special thank to #Yazan who gave me a prompt.

Map not showing

I have a Map inside a fragment. Until now, it showed correctly. Now, I see the Google logo, the +/- buttons and a grey surface with squares (it's not the typical blank background) but I don't see the map.
The logcat is showing continuosly this:
31 11:47:21.413: D/REQUEST(30479): Connection opened to:https://clients4.google.com/glm/mmap/api
10-31 11:47:21.413: D/REQUEST(30479): Open Connection
10-31 11:47:22.294: D/REQUEST(30479): DRD(42): 62|147|7|108
10-31 11:47:22.294: D/REQUEST(30479): Close
10-31 11:47:22.294: D/REQUEST(30479): Error processing: com.google.maps.api.android.lib6.b.d#43ba8a58 not retrying
10-31 11:47:22.304: D/REQUEST(30479): Retrying: com.google.maps.api.android.lib6.c.au#436cc688
10-31 11:47:22.304: D/REQUEST(30479): Retrying: com.google.maps.api.android.lib6.b.v#43900930
10-31 11:47:22.324: D/REQUEST(30479): Retrying: com.google.maps.api.android.lib6.gmm6.m.af#43375668
10-31 11:47:34.246: D/REQUEST(30479): Connection opened to:https://clients4.google.com/glm/mmap/api
10-31 11:47:34.246: D/REQUEST(30479): Open Connection
10-31 11:47:35.277: D/REQUEST(30479): DRD(43): 62|147|7|108
10-31 11:47:35.277: D/REQUEST(30479): Close
Edit- Code added:
private void checkMap() {
if (mMap == null) {
/*Try to obtain the map from the SupportMapFragment*/
mMap = ((SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
/*Check if we were successful in obtaining the map.*/
if (mMap != null) {
initMap();
}
}
}
private void initMap() {
/*Get location*/
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
/*Set criteria*/
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String provider = locationManager.getBestProvider(criteria, true);
/*Get last known location if exists*/
defaultLocation = locationManager.getLastKnownLocation(provider);
/*If last known location doesn't exist request a single update*/
if (defaultLocation == null) {
locationManager.requestSingleUpdate(criteria, new LocationListener() {
#Override
public void onLocationChanged(Location location) {
defaultLocation = location;
}
#Override
public void onProviderEnabled(String provider) {
}
#Override
public void onProviderDisabled(String provider) {
}
#Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}, getActivity().getMainLooper());
}
/*Move camera*/
if (defaultLocation != null) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(defaultLocation.getLatitude(), defaultLocation.getLongitude()), 5));
}
}
Manifest:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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"/>
<!-- 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"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="..."/>
Finally I've got a solution. If you use private keystore to apply API_KEY, you cannot upload and install application with eclipse, for that, you have to use a debug key. If you want to see the map using a private keystore, you need to upload .apk file to your device by yourself and install it.
Please Try Following way
First Check your API Key Generated Is Correctlly and IT Active Or Not API CONSOLE
Add Permission Of Signiture.
Add Permission Of gsf
Check SDK min Version And Max Version
If you run on emulator then you nedd to install these two apk file from cmd pormt.
Links for Download...
1)https://www.dropbox.com/s/ccnuqmsxdtb75xl/com.android.vending.apk
Open the AVD
Execute this in the terminal / cmd
adb -e install com.google.android.gms.apk
adb -e install com.android.vending.apk
adb install com.google.android.apps.maps-1.apk
adb install com.google.android.gms-2.apk
Whole Menefist File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dilip.googlemapsv2"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.dilip.googlemapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="20" />
<uses-permission android:name="com.dilip.googlemapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<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=".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>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Your API Generated Key" /> /* Added Bi Dilip */
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>

Can´t run my app with google maps api v2

I tried everything, I researched and I can't get run my application. Each time I Run my application on my device get the message: "Sorry, Map has been has been interrupted". I done all the steps from this page https://developers.google.com/maps/documentation/android/start?hl=pl, and follow many tutorial and nothing. I hope you can save me.
Manifeste File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.map"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.example.map.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.map.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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.map.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>
<!-- Goolge Maps API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBEGWDP9v4HepDF9A1NmSfFYjfdU2Jezm4" />
</application>
</manifest>
XML File:
<?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" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
And my MainActivity:
package com.example.map;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends Activity {
// Google Map
private GoogleMap googleMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
protected void onResume() {
super.onResume();
initilizeMap();
}
}
Please Help me!!!!
try this :
class="com.google.android.gms.maps.SupportMapFragment"
on your activity :
SupportMapFragment mapfragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.showmap);
I think your problem in
android:name="com.google.android.gms.maps.MapFragment"
try instead of this, in the way:
class="com.google.android.gms.maps.MapFragment"
P.S. sometimes problem with maps is in not available Google Play Service on device.
(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS)
must be true.

Google map not showing on android (signed apk) with Google V2 release key

I am exactly following step Given here.
API key is obtained by following steps Here
i already upload the apk on market for test purpose but still its not showing map although it display map with debug key.but when i try to use release Google map key its showing white screen with zoomin and zoomout button but no maps.
Google play store link
MapFragment
public class CustomMap extends SupportMapFragment {
private static final int ZOOMIN_ANIMATION_DURATION = 300;
public static CustomMap newInstance() {
Bundle bundle = new Bundle();
CustomMap customMap = new CustomMap();
customMap.setArguments(bundle);
return customMap;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
#Override
public void onResume() {
super.onResume();
GoogleMap googleMap = getMap();
if (googleMap == null) {
} else {
LatLng mLatLng = new LatLng(70.00,
33.00);
googleMap.addMarker(new MarkerOptions()
.title("Title")
.snippet("Address")
.position(mLatLng)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(mLatLng));
googleMap.animateCamera(CameraUpdateFactory.zoomBy(10),
ZOOMIN_ANIMATION_DURATION, null);
}
}
}
Main Activity
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
XML
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<fragment
android:id="#+id/fragment1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
class="com.example.maptest.CustomMap"
/>
</RelativeLayout>
Manifest
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.baresso.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-permission android:name="com.baresso.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.maptest.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="AIzaSyDcAy3bEVhv_lhAH1hHNHk_RpvyXiN0xNI" />
</application>
</manifest>
https://developers.google.com/maps/documentation/android/start
I think the problem is with the Obtaining an API Key Or With The SHA-1 Finger Print.
have You Give the application Package with the SHA-1 fingerprint in the
Google Consol
install Google Play Service into Your Emulator or Android Device.
Please prefer Android Device for Map Testing .
Google Maps Will not work with the latest change in their policies which limits the usage of google map libraries directly.
To solve this either you have to include entire google maps as a third party plug in or you can display the google map in an webview and pass locations through a javascript html function.
for ex:--
<script>
function initialize()
{
document.getElementById('dummyDIV').innerHTML = '<div id="googleMap"
style="width:'+screen.width+'px;height:'+screen.height+'px;"></div>';
var sURL1 = window.document.URL;
var sURL2 =sURL1.split("%20");
var sURL= sURL2[0];
for (j=1;j<sURL2.length;j++){
sURL = sURL+' '+sURL2[j];
}
var mapProp = {
center:new google.maps.LatLng(19.155721,72.856025),
zoom:10,
disableDefaultUI:true,
zoomControl:true,
mapTypeControl:true,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
if (sURL.indexOf("?") > 0)
{
var bifurcatedURL = sURL.split("?");
var everyMarker = bifurcatedURL[1].split("&");
for (i=0;i<everyMarker.length;i++)
{
var markerDetails =everyMarker[i].split("+");
var lat = (markerDetails[0]);
var lon = (markerDetails[1]);
var address =markerDetails[2];
var type = markerDetails[3];
var markerPosition = new google.maps.LatLng(lat,lon);
map.setCenter(markerPosition);
if(type=='a'||type=='A')
var marker=new
google.maps.Marker({position:markerPosition,icon:'atm_marker.png'});
else if(type=='b'||type=='B')
var marker=new google.maps.Marker
({position:markerPosition,icon:'branch_marker.png'});
else if(type=='c'||type=='C')
var marker=new google.maps.Marker({position:markerPosition,icon:'pin_blue.png'});
marker.setMap(map);
var infowindow = new google.maps.InfoWindow({content:address});
listenMarker(marker,address,infowindow,map)
}
}
}
function listenMarker (marker,address,infowindow,map)
{
// so marker is associated with the closure created for the listenMarker function call
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
problem's lying here
<permission
android:name="com.baresso.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
replace it with giving your own package name..
<permission
android:name="com.example.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
and here
replace this
<uses-permission android:name="com.baresso.permission.MAPS_RECEIVE" />
with <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE" />
copy SHA1 from logcat when you siged your apk click on finish and add this on your google play developer console project SHA-1 certificate fingerprint this will show your map with signeg apk

Categories

Resources