NOTE: Version 1 of the Google Maps Android API has been officially deprecated as of December 3rd, 2012 . This means that from March 3rd , 2013 you will no longer will able to request an API key for this version. No new features will be added to Google Maps API v1 . However , apps using v1 will continue work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.
NOTE: You cannot run your application using Google Play API(Google Maps Android API V2) on Android emulator, Because your emulator doesn't support Google Play services. So you need to check your application in Android mobile phone which supports google play services.
watch video tutorial here:click here
download this project here :GoogleMapsAndroidAPIV2
Here i'm giving the procedure how to setup Google Map Android API v2 SDK and integrating in Application.
ScreenShot:
Step1: Download and configure the Google Play Services SDK. In Eclipse open go to window menu
and run Android SDK Manager and under Extras select Google Play Services package and
download it.
Step 2: Now create your application where you want use Google maps api v2.
Step 3: Import Google Play Services library project in eclipse
Next again perform same action.
Note: you will get this problem because of lengthy path.
After executing above command you will get SHA1 certificate fingerpint key copy that and go to internet and in Google type google api console and there sign in using your google account.
Step 5: Sign in google api console website as follows
Step 6: After signing in follow the steps below
-->In following window scroll down and activate Google Maps Android API v2 Services by clicking on OFF button to ON
NOTE: You cannot run your application using Google Play API(Google Maps Android API V2) on Android emulator, Because your emulator doesn't support Google Play services. So you need to check your application in Android mobile phone which supports google play services.
watch video tutorial here:click here
download this project here :GoogleMapsAndroidAPIV2
Here i'm giving the procedure how to setup Google Map Android API v2 SDK and integrating in Application.
ScreenShot:
Step1: Download and configure the Google Play Services SDK. In Eclipse open go to window menu
and run Android SDK Manager and under Extras select Google Play Services package and
download it.
Step 2: Now create your application where you want use Google maps api v2.
Step 3: Import Google Play Services library project in eclipse
- Under package explorer right click choose import option and under android choose importing existing project into workspace as follows.
- In next window choose browse option and open your ADT Bundle has been located or your Android SDK and inside open extras folder and open google folder and open google_play _service folder and choose libproject folder and click ok button.
- After clicking ok button under Import Project window select google play service lib project and click finish button.
- After clicking finish button you will observe in under package explorer google_play_services_lib project has been added.
Step4: Adding googleplay_services_lib to our project:
- Right click on project and choose properties option and select android .
- Under library choose add option and add googleplay_service_library to our project as follows:
Next
- Right click on project and choose properties option and select android and if you got following error under library then follow the bellow procedure.
open adt bundle -->open sdk folder-->open extras folder-->open google folder-->open googleplayservices folder-->copy lib project and paste in your current workspace folder and from there import libproject after importing add library to the project now you wont get any error.
Step5: Finding SHA1 fingerprint key
Now two ways are avialable to findout SHA1 key
Procedure1:
- Go to window menu choose preferences under preferences choose android under that choose build and copy SHA1 fingerprint key as follows:
or
Procedure 2:
- If your using windows operation system follow below procedure
- Under package explorer right click and choose properties.
- Under Android choose build and there you can see default debug keystore copy that keystore value.
- After goto MyComputer and open the drive where your operating system has been located and under that drive open program files folder there you will see java folder open that and open jre folder on bin folder click SHIFT+Right click choose open command window here and type following command.
keytool -list -v
-alias androiddebugkey -keystore "paste your default debug keystore here" -storepass android -keypass android- After executing above command you will get SHA1 certificate fingerpint key copy that and go to internet and in Google type google api console and there sign in using your google account.
- If your using Mac or Linux operating system procedure is very easy just type following command in Terminal
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
After executing above command you will get SHA1 certificate fingerpint key copy that and go to internet and in Google type google api console and there sign in using your google account.
Step 5: Sign in google api console website as follows
Next
Step 6: After signing in follow the steps below
- -->Under google api's console select create project option as follows
Next
-->provide project name and select create button.
Next
-->After selecting create button you will get following window.
-->In following window from left side navigation bar select APIs & auth option as follows
Next
Next
Next
-->Select Credentials option from left side navigation bar under APIs option
Next
-->After selecting Credentials option next you will get following window
-->From following window select CREATE NEW KEY option
- In following window enter your SHA1 cerficate fingerprint key (go to step5)with semicolon and after enter your application package name as follows.
- And click create button.
Step 7: Go to eclipse open your application and open AndroidManifest.xml file and insert following code .
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ram.googlemapsv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<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" />
<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" />
<permission
android:name="your application package name.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="your application package name.permission.MAPS_RECEIVE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.ram.googlemapsv2.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.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="paste your api key here" />
</application>
</manifest>
Step 8: Insert following code in your activity_main.xml
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
/>
</LinearLayout>
Step 9: Insert following code in your MainActivity.java
MainActivity.java:
package com.ram.googlemapsv2;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
public class MainActivity extends Activity {
GoogleMap map;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
// map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
// map.setMapType(GoogleMap.MAP_TYPE_NONE);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
// map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
// map.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
}
}
eclipse not showing module named GoogleMap? :(
ReplyDeleteNice article dude...Keep it up..
ReplyDeleteThanQ very much
ReplyDeletehello sir,
ReplyDeletei got error
android library project can not be launched ...
select the project, right click->Properties. On the left pane, click Android... Uncheck the "isLibrary" checkbox. Give Ok. Now execute. :)
Deletemake sure that you have downloaded google play services package from android sdk manager...
ReplyDeleteit is possible for current location to for example Uk country draw line path using mapping v2 version .. I think am waiting for code last two months
ReplyDeleteam getting code throught india . its is possible or not please tell me sir..
i also get this error
ReplyDeletegood tutorials sir... always update. very helpful
ReplyDeleteThanQ very much Subhani i will update the tutorials soon...
DeleteHi Amit execute the map application real device not in emulater..i will upload video tutorial soon for more reference...
ReplyDeletei draw a line from hyderabad to unitedstates of kingdom ..
ReplyDeletethis error came
Out of memory (enhanced)
Sir waiting for ur response no body can tell answer that's wise am sending the message many times
ReplyDeletesir i use this code and run my project then i have one unwanted error like a
ReplyDelete1)..>06-18 18:49:18.993: E/Google Maps Android API(13743): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
2)..>
06-18 18:49:19.003: E/Google Maps Android API(13743): Ensure that the following correspond to what is in the API Console: Package Name: org.infoware.googlemapapiversion2demo, API Key: AIzaSyAuEW5JOZaA36GhN9mjTyXoTMBv88WsWFc, Certificate Fingerprint: B268A7D63AFC8F158D3E1F4AE899CE8DF528074D
3)..>
06-18 18:49:23.918: I/Google Maps Android API(13743): Failed to contact Google servers. Another attempt will be made when connectivity is established.
4)..>
06-18 18:49:24.519: E/Google Maps Android API(13743): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
sir i got this type four error.i try to my best to solve this.but can't success.and it's strange that my one app in witch i use the google map v2 it's live on app store and work perfectly.
so i am not new for google map.but i can't solve this.error.please help me.
Hi this is the problem with authentication from google ..once checkout your SHA1 certificate key and map api key
DeleteHi,
DeleteThe api Key is not matching with full project name after the SHA1 finger print pls check the project name in google api console the project name and generated key these both should be given in manifest file.
out of memory (enhanced) occured in android
ReplyDeletetutorial very nice but I my program fail while executing , its not even opening app , giving error.
ReplyDeleteSoon i will upload video tutorail
Deletemap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
DeleteI am getting erroe in this line as create method getFragmentManager(), if I create also i am getting error in findFragmentById(R.id.map)
I am also getting same problem.........
Deleteif your getting error in java code the problem is with the library once again check the library added to the project or not..
Deletecheckout my updated maps tutorial
Hi Rams M,
ReplyDeleteHow to show driving direction between two geocodes? i'm getting only straight line between them. can u help me out. thanks in advance for your time and consideration
Hi Rams M,
ReplyDeletePlease help us
how to solve this issue
07-07 07:38:03.983: E/AndroidRuntime(902): FATAL EXCEPTION: main
07-07 07:38:03.983: E/AndroidRuntime(902): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
07-07 07:38:03.983: E/AndroidRuntime(902): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
07-07 07:38:03.983: E/AndroidRuntime(902): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
Map is not coming after publishing it on google play store..... do anyone know why it is happening.......
ReplyDeletePleae solve this error
ReplyDeleteCould not find class 'com.google.android.gms.maps.MapFragment', referenced from method com.example.myandroidgooglemap.MainActivity.onCreate
android.view.InflateException: Binary XML file line #9: Error inflating class fragment
This comment has been removed by the author.
DeleteI didn't get the SHA1 fingerprint key. give some idea
ReplyDeletelocation.getLatitude() + "location.getLongitude(),
ReplyDeletewhy error ?
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
ReplyDeleteOn this line i am getting error "The method getFragmentManager() is undefined"
My java file does not find the class GoogleMap...as a result i cannot create the object of GoogleMap class.What should I do??Please help.
ReplyDeleteThe information which you provides is very much useful for the Android Learners. Thank you for your valuable information. I found 123trainings is the best Android Online Traininginstitute in Hyderabad, India .
ReplyDeleteany solution? I also have such issue now.
ReplyDeleteI have followd all these steps. No errors while designing the app. But on running, A message appeared inside simulator: Google Bridge services, which some of your Applications rely on , is not suppoerted by your device.Please contact the manufacturer for assistence. - is coming. how to solve this? As I thought it may work on real device, there also It is failing, showing Force close Dialog.
ReplyDeleteHi Harishbabu ,make sure you have google play services apk installed in your mobile by executing following code
Deleteint resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (resultCode == ConnectionResult.SUCCESS){
Toast.makeText(getApplicationContext(),
"isGooglePlayServicesAvailable SUCCESS",
Toast.LENGTH_LONG).show();
}else{
GooglePlayServicesUtil.getErrorDialog(resultCode, this, RQS_GooglePlayServices);
}
Hi Sir,
ReplyDeleteCould you please clarify me about what is the value to kept at android:value="@integer/google_play_services_version".
It is giving error in Manifest File.
same value what i have given: android:value="@integer/google_play_services_version"
ReplyDeleteand you should update google play services library from your sdk manager
E/MapActivity(3610): Couldn't get connection factory client
ReplyDeleteFollowed tutorial to the tee and yet I get "The application xxxxx (process com.example.xxxxx) has stopped unexpectedly. Please try again.
ReplyDeleteI am running this on a HTC Wildfire ADR6225.
Habe worked on this for the entire Xmas break with no success.
Console
Starting activity com.example.ksmap.MainActivity on device HT22EHR00049
Logcat
01-09 21:59:29.040: I/dalvikvm(7503): Could not find method com.example.ksmap.MainActivity.getFragmentManager, referenced from method com.example.ksmap.MainActivity.onCreate
01-09 21:59:29.040: W/dalvikvm(7503): VFY: unable to resolve virtual method 4468: Lcom/example/ksmap/MainActivity;.getFragmentManager ()Landroid/app/FragmentManager;
01-09 21:59:29.040: D/dalvikvm(7503): VFY: replacing opcode 0x6e at 0x0008
01-09 21:59:29.040: D/dalvikvm(7503): VFY: dead code 0x000b-0021 in Lcom/example/ksmap/MainActivity;.onCreate (Landroid/os/Bundle;)V
01-09 21:59:29.090: D/AndroidRuntime(7503): Shutting down VM
01-09 21:59:29.090: W/dalvikvm(7503): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
01-09 21:59:29.120: E/AndroidRuntime(7503): FATAL EXCEPTION: main
01-09 21:59:29.120: E/AndroidRuntime(7503): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ksmap/com.example.ksmap.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
01-09 21:59:29.120: E/AndroidRuntime(7503): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
01-09 21:59:29.120: E/AndroidRuntime(7503): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
01-09 21:59:29.120: E/AndroidRuntime(7503): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
01-09 21:59:29.120: E/AndroidRuntime(7503): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
hi Randy sorry for late reply.
Deletecan you post the xml code and java code so that i can easily tell you what is the problem
Hi Sir. There's no error with the project but when i run it it says "01-20 20:52:16.522: E/AndroidRuntime(274): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlemap/com.example.googlemap.MainActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
ReplyDelete"
Please help me.
right click on project and choose properties and select android and right side bottom check if you have any error in library project if you have error checkout the solution in my maps post
DeleteHi. There's no error with the library. I have already followed the steps you gave. I really don't know what's the problem with this. everytime i run the program it gives inflationexception error.
Deleteok clark give me your gmail id.
Deletewe will discuss about your problem through gtalk
in google+. try to check.
DeleteI chat you in google+ Hangouts. Try to check that.
Deletehi,
ReplyDeletesir i have dun completely bt my application code give error unfortunately application has stopped .....mailid:-amit.sharma.himcs@gmail.com
manufeast file code is :-
attach the error what your getting. go to window menu and select open perspective select the DDMS under DDMS make logcat tool full window and there you can observe errors means exceptions post them here . so i can help you
DeleteHi Rams,
ReplyDeleteThanks for the tutorial, just excellent !!!
Have one query, in my case, i would like to launch the google map, from another main app, which would have a button, "Launch Map", and this button should launch the google map. Not sure how to do this, could you please help me out ?
you can do using Intent and startActivity()
DeleteSir, I have following ur step but can't run the application so pls help me how can solve my problem...my xml,java and manifest is below check it....fsrt reply....with ur best solution.....
ReplyDeleteMy API key and google play service is install and add with to my project.....is ready
SOME ERROR IS LIST BELOW
DialogBox will be open in contain this error.
Unable to execute dex: java heap space.
An internal error occurred during: "Processing Dirty Regoin". Java heap space.
THEN Ok press
Your Code and My code are same but error will be happen is above....
XML FILE HERE:
JAVA CODE HERE:
package com.example.demomaps;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
public class MainActivity extends Activity
{
GoogleMap map;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
// map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
// map.setMapType(GoogleMap.MAP_TYPE_NONE);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
// map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
// map.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
}
}
AndroidMenifest.xml HERE:
Sir i use google play service version 14 installed..
ReplyDeletei can apply my application in android 4.2 with API level 17.
I need to see the code in eclipse then only i can solve the problem..and yeah you can upgrade to any version that is not problem
Deletehi, i am using linux ubuntu, and i tried all the ways to run Map application on the emulator... it failed every time, so please help me to run it.
ReplyDeleteHi Mamata you cannot run maps app in emulator.
ReplyDeleteTry to run in real device
Hi Rams, thanks for the help in the tutorial. I followed it, but when I try to run it on my phone, it just say "Unfortunately, MapsV2Demo has stopped." Can you help? Please see the attached pictures for screenshots of my xmls, .java and my Logcat output
ReplyDeletehttp://imgur.com/a/dcASD
I made a mistake and uploaded the wrong screenshot on the last one on that album, here is the proper one
Deletehttp://imgur.com/OOnQrc5
Thanks,
Nick
Watch this video once and let me know again if u have problem.
Deletehttp://www.youtube.com/watch?v=E780gbh6vLU
I watched the video initially, but I still have this problem. This is the same problem I had when I tried to follow another online guide for getting the Google Maps API to work too
Deletethanks,
Nick
ok this is my mail id ..rams4android@gmail.com
Deleteyou can contact me to this mail id i will see your code
Hey, very informative and great post, may help to the students who are searching for a Training solutions New, by your post they con filer out best Training for them.
ReplyDeleteAndroid Institute in gurgaon
hello, very nice tutorial. I am having an issue when i run the app on my phone the map displayed is blank white. I am exporting the project as .apk file and installing it on my device. Could this cause issue?
ReplyDeletei made it work finally.THANKS A LOTTTTTTTTTT :)
DeleteHow did you make it work? Please help. Many Thanks
DeleteThank you...helps a lot - I liked your youtube videos as welll--Cheers from Sydney, Australia !!!!
ReplyDeleteHi i have seen your reply in youtube.
Deleteyou can contact me through this mail id :rambab.mareedu@gmail.com
it works... amazing tutorial...
ReplyDeletethanks for shareing These are truly good ideas in regarding blogging You have touched some good things here. Any way keep shreing this information
ReplyDeletehttp://www.allmoh.in/seo-training-in-hyderabad/
i got one problem i see it in my debug window
ReplyDeletesource not found.!!
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2231
sorry i follow your video to write my code
ReplyDeletebut error message show
"activity_main.xml: Failed to find style 'mapViewStyle' in current theme"
how can i fix this error
please teach me thank you
This comment has been removed by the author.
ReplyDeleteThanks for sharing such a great blog Keep posting..
ReplyDeleteAndroid Training in Delhi
Thanks for this blog, Learn more on Android Online Training
ReplyDeleteSuch a nice blog Thanks for sharing information Activate Google Account.
ReplyDeletehttp://chennaitraining.in/abinitio-training-in-chennai/
ReplyDeletehttp://chennaitraining.in/pentaho-training-in-chennai/
http://chennaitraining.in/msbi-training-in-chennai/
http://chennaitraining.in/informatica-mdm-training-in-chennai/
http://chennaitraining.in/informatica-data-quality-training-in-chennai/
http://chennaitraining.in/informatica-iics-training-in-chennai/
http://chennaitraining.in/talend-training-in-chennai/
http://chennaitraining.in/power-bi-training-in-chennai/
http://chennaitraining.in/sap-bo-training-in-chennai/
http://chennaitraining.in/qlikview-training-in-chennai/
This comment has been removed by the author.
ReplyDeleteMobile event app creation software is often used as a supplement to other event management platforms or event planning software. event marketing and How to Choose Best Mobile Event Apps in 2021
ReplyDeletegood to read your content, well written!
ReplyDeleteData Science Training in Pune
Jean Muggli :- Jean Muggli came to popularity as the former wife of Michael Strahan, a retired professional American football player
ReplyDeleteCourtney Thorne-Smith :- Courtney Thorne-Smith is an American actress known for her multiple roles in some of the popular television series of all time.
Brooke Daniells :- Brooke Daniells is a popular and professional photographer from the United States of Americ
Simeon Panda :- Simeon Panda is a true role model for anyone who wishes to achieve success in the field of bodybuilding.
Faye Chrisley :- Faye Chrisley is an American reality TV star. She is well-known for playing Nanny in the American TV series Chrisley Knows Best.
Christi Pirro :- Christi Pirro is a lawyer and a law clerk. She is well-known as Jeanine Pirro’s daughter. Jeannie, her mother, is a TV broadcaster and writer.
Pokimane :- Pokimane is a famous Canadian twitch streamer and YouTuber. However, she is famous for her streaming on games. So, she mostly played two games
mmorpg
ReplyDeleteinstagram takipçi satın al
tiktok jeton hilesi
Tiktok jeton hilesi
antalya saç ekim
referans kimliği nedir
İnstagram Takipçi Satın Al
Metin Pvp
takipçi
Smm panel
ReplyDeleteSmm Panel
isilanlariblog.com
instagram takipçi satın al
hirdavatciburada.com
https://www.beyazesyateknikservisi.com.tr
Servis
tiktok jeton hilesi