Add Google Maps API v2 in Mono for Android
Asked Answered
S

4

7

Google Maps API v2 for Android released on 3th December.

Is there any possibility to add it into Mono for Android?

Semirigid answered 9/12, 2012 at 19:28 Comment(0)
S
10

I tried the guide suggested by TheNextman, but wasn't able to make it work, so after several hours I managed to make it work using the following steps:

  1. Download the latest sample Projects from Xamarin's Github page.

  2. Open monodroid-samples\MapsAndLocationDemo_v2\MapsAndLocationDemo.sln on MonoDevelop

  3. Open the Android SDK Manager and download "Google Play Services" from the Extras section

  4. Copy \extras\google\google_play_services\libproject\google-play-services_lib to monodroid-samples\MapsAndLocationDemo_v2\

  5. Open a command prompt and cd to monodroid-samples\MapsAndLocationDemo_v2\google-play-services_lib

  6. Type the following two commands:

    android update project -p .

    ant debug

  7. Now on MonoDevelop Add the file google-play-services_lib/project.properties to the GooglePlayServices project as a linked file

  8. Now create a Google Maps API key . Two things to keep in mind though:

    The default location of the debug keystore when using MonoDroid is :

    Windows Vista / Windows 7 / Windows 8: C:\Users[USERNAME]\AppData\Local\Xamarin\Mono for Android\debug.keystore OSX : /Users/[USERNAME]/.local/share/Xamarin/Mono for Android/debug.keystore

    You can find the package name on the MapsAndLocationDemo/Properties/AndroidManifest.xml file in the manifest tag.

  9. If you are deplyoing to a real device then that is all, if you are deploying on the emulator keep reading

  10. Create a new AVD with this setup: Platform: 4.1.2 CPU: ARM Leave the default options for the rest of parameters

  11. Grab the vending.apk (com.android.vending.apk) and the gms.apk ( com.google.android.gms.apk) from a real device (Look at the end of this post for more details)

  12. Start the emulator you just created and then open a command prompt and cd to the folder where you downloaded the APKs

  13. Type:

    adb -e install vending.apk adb -e install gms.apk

  14. Enjoy!

Sources:

(1) https://github.com/xamarin/monodroid-samples/tree/master/MapsAndLocationDemo_v2

(2) This app won't run unless you update Google Play Services (via Bazaar) Check danbrough's comment. If possible extract the two APKs com.android.vending and com.google.android.gms from a rooted Device to get an updated version of the library.

Shoelace answered 17/1, 2013 at 22:48 Comment(5)
Ok, I forgot to link the "tools" and "platform-tools" in the "PATH" variable. Also i didn't install the Apache Ant. Now everything works. But it says everytime "SupportMapFragment doesn't exist...". What is the reason and what can I do?Semirigid
Try referencing the dll directly and not the project, sometimes VS can't find types when they are linked from a project. You should find the dll on the bin folder of the Google Services library projectShoelace
Hmm.. Theres no dll in the project.Semirigid
Try building the Google Services project in Visual Studio, if it doesn't give you any errors it should build a dll inside the GoogleServices/bin/Release or GoogleServices/bin/Debug folderShoelace
It is such a pain to use Google Maps. I wish it would be easier to use Google Maps in XamarinWile
B
1

For those who use a Mac, there is a bash script that will take care of building the Google Play Services client for you. It does assume that you have the environment variable $ANDROID_HOME set (the path to the Android SDK) and Apache Ant installed.

Borak answered 14/3, 2013 at 21:42 Comment(0)
M
0

Here is a good guide to get this working: Using the New Google Maps With Mono for Android

Meghan answered 11/12, 2012 at 14:31 Comment(0)
R
0

About jucas comment

Try referencing the dll directly and not the project, sometimes VS can't find types when they are linked from a project. You should find the dll on the bin folder of the Google Services library project

For me it helps to remove reference to Mono.Android then add project reference to GooglePlayServices and and reference to Mono.Android. I don't know why it works but it does.

Roubaix answered 11/7, 2013 at 11:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.