What are the dependencies of Google Maps v2? - android

I am new to Android and want to embed Google Maps v2 to my application, but can anyone please tell me which dependencies should I install on phone or include to project?

Include Gradle dependency:
dependencies {
implementation 'com.google.android.gms:play-services-maps:16.1.0'
}
You may found Gradle, please helpful. Also, check out this page for Android APIs releases.

I assume you have already read https://developers.google.com/maps/documentation/android/ :-)
In short:
you need to download and install the Google Play service lib via SDK manager
create a project in Eclipse via "Create project from existing source code" and use the source code from "\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib"
add this project as dependency to your actual project via right click on your project -> properties -> android -> add project library
add the permissions as described in the link mentioned above
request an API key as pointed out in the link above as well
add a SupportedMapFragment to your layout
you need an active Google account on the device to will test your map (it will install the required dependencies on the device automatically then)
That's it :-)
Hope that helps....

Related

Google play services version conflict in app with third-party library

I used third party library (.jar) which has dependencies on play-services:6.5.87 and my main app module use play-services-gcm:8.3.0 which is latest version. Both upgrading to 8.+ from 6.+ and downgrading from 8.+ to 6.+ doesn't work and have build error.
Please do comment if you find my question confused, i will try provide detail explanation as much as i can . Thanks
After couples hours of googling , i figured out to run successfully. Google has made update on google-play-services api in 8.+ and remove some of the impl which they once had in 6.+ but 7.+ don't. See here for play service api release notes . Since third party library use google location service.My app has depend on new impl of GCM ( 8.+) . Changing version to 7.8.0 esp solve my issue .
Things learned here is if you don't neccessary have to depend on third party which use seperate google-play-service, don't waste time on that. Otherwise use alternative library. Beacause the only way you solve this prob is , ask library supporter to build (.aar) version with latest google-play-servies. If not you may fall into the same issue I did.
Hopt it helps
check your build.gradle file and android build version.
compile 'com.google.android.gms:play-services:8.1.0'//updated version you can put
and check android build version you installed.
compile 'com.google.android.gms:play-services-gcm:8.1.0'//updated version you can put.
or
go file->project structure-> dependency tab -> add Library dependency(available google play services)

Can't get the google_play_services_version value after setting the google services API

I've set the Google play services API on my android app project, I did as I saw in the documentation for google android developer. I started by copying the google library services in the folder of my project, then I added the refernce in the build (like we see in the photo the gooogle play services lib is perfectly deployed) and then I tried to copy this piece of code in android but manifiest not recognize the second line. android:value="#integer/google_play_services_version"
So any help for that please ! Thanks
Xavier is right, there are no resources in the GooglePlayServices JAR file you usually get your compiled classes.
As you're in Android Studio you can just add to your gradle dependencies : compile 'com.google.android.gms:play-services:5.2.08'

How To Find Android Google Play Services Version

I'm working on an android project which requires the use of google maps. I've been reading tutorials, and I have to add this to the AndroidManifest.xml file:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
The thing is, I don't know what number to substitute the "#integer/google_play_services_version" with.
If anyone knows what I should enter there, and how to obtain that integer value, I'd appreciate it.
There is no need to subsitute. The value #integer/google_play_services_version takes care of it. Just make sure you have the latest Google Play Services library which is updated.
You can find it under google-play-services_lib>res>values>version.xml if you wish to add the number rather than #integer/google_play_services_version.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">4030500</integer>
</resources>
Here is the official guide for setting up Google Play Services in your project.
FYI, you could find the version number in this folder:
~\android-studio\sdk\extras\google\m2repository\com\google\android\gms\play-services
Enjoy.
Error you have mentioned is maybe because of not adding Google play services lib as library of your project do the following.
Select File -> Import -> Android -> Existing Android Code Into Workspace and click Next.
Select Browse, enter
/extras/google/google_play_services/libproject/google-play-services_lib, and click Open.
3.Select Copy projects into workspace and click Finish.
Mark Google Play services as a library: Right-click the google-play-services_lib project, and choose Properties > Android. Tick the Is Library option.
Right click on your project -> go to properties -> click android -> click add button -> click google_play_services_lib -> ok -> apply -> ok clean your project
this will remove your error
If you are using gradle just make sure you have the updated google play services version (downloaded using SDK manager) and put this in your project module dependency section:
compile 'com.google.android.gms:play-services:+'
IMPORTANT NOTE: In general it is not a good practice to remove the concrete version of the source you are compiling against.
I was in a case where I had to use the Froyo version of the Google Play Services, and that version doesn't require the tag. In fact, the XML entry google_play_services_version does not exist in the Froyo+ version of the Google Play Services library

Android Studio Maps Api v2

My code works perfectly on eclipse. I have created a new project on Android Studio and added my classes, I have also followed this popular tutorial answer How can I create an Android application in Android Studio that uses the Google Maps Api v2?
Now the code doesn't show any red flags and it detects the imports fine but when I build the project I get these errors:
Gradle: package com.google.android.gms.maps does not exist
Gradle: package com.google.android.gms.maps.model does not exist
On a side note I have attempted to import the MAPS sample project like the tutorial says and that has worked fine but I do not know why my new project gives me these errors even though I have followed the tutorial to the letter.
Any idea guys?
If you created a new project (which uses Gradle) and then followed the tutorial, it's completely wrong.
When using Gradle (which new projects do by default), you cannot use the UI to add dependencies. You need to add them manually in build.gradle.
It's a crappy solution right now and we're working to make this better.
In short words:
Run Android Studio
Create new project
Create new module of Android Library type, remember to set the package name to com.google.android.gms
Copy res, src folders and AndroidManifest.xml file from google-play-services_lib (you can find it in your SDK folder if you installed it using SDK Manager) to the appropriate folder in your library module ([Project]/[Library]/src/main)
Remove android-support-v4.jar from libs folder under your library module, live only google-play-services.jar and google-play-services.jar.properties files there.
Make sure your build.gradle file in library module contains following:
dependencies {
compile files('libs/google-play-services.jar')
}
Make sure your build.gradle for application module contains following:
dependencies {
compile files('libs/android-support-v4.jar')
compile project(':[LibraryModuleName]')
}
Make sure your settings.gradle contain following:
include ':MapStudio', ':[LibraryModuleName]'
You can grab layout and manifest settings from Google Maps API v2 tutorial
Keep in mind that android-support-v4.jar is neccessary only when you want to support Android v2
You can find more detailed description on my blog.
I have tried and failed many a tutorial on this, but finally find a simple solution that seem to work.
I just installed Android Studio 0.2.3 on my mac, and these are the steps that made me view a maps fragment on a fresh hello world project template:
1) Click the SDK manager button in the toolbar in Android Studio.
2) Under 'Extras' locate 'Google play services' and install it.
3) in your build.gradle file in your src directory, add this line to dependencies:
compile 'com.google.android.gms:play-services:3.1.36'
4) order and install your API-key following this tutorial: https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key
5) add the fragment to your layout xml:
<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"/>
6) you should now be able to run your project on your device.
For those of you completely confused by everything going on with implementation of external libraries to gradle projects i have the easiest and most reliable solution.
Step by Step Guide: http://aetherstudios.net/pages/gradle.html
this might be a bit of work but it is the most reliable way i have found to get it done.

Android Dependencies Issue

I am writing a MAP APP using Android Google Maps V2
But i am facing dependency problem, please see below images:
as you can see in above screen shot i am getting RedAlert Sign over Project Name
and as you can see in above screen shot getting RedCross over Android Dependencies
#ChulbulPandey
In Eclipse open Project -> Properties. Select Android on left. Check on the bottom that you have a reference to Google play services with a green checkmark. If not, click Add and add the google play services library
Path of google-play-services_lib at SDK;
\extras\google\google_play_services\libproject\google-play-services_lib
I am not sure but you can try this.
In Libraries tab remove the Google Maps V2 jar and add it again.
First, try changing project build target to something higher and then clean then build your project.
If that doesn't solve your issue then removing your external jar files linked and then import it again.
You must import google-play-services_lib library project from SDK and add a dependency to it from your project.
Path of google-play-services_lib at SDK;
\extras\google\google_play_services\libproject\google-play-services_lib
See link

Categories

Resources