I've been trying to include the latest Google Play Services library to my Android Studio project in order to use push messages and Maps API.
Since there are plenty of tutorials on how to include this library on Eclipse and CLI , there are no instructions on how to include the latest library on Android Studio.
I've been searching on many sites and one of the answers which looked to be the most fitting looked to be this one, since other ones appear to document an older version, but it still appears like I'm missing something.
I've tried to include this lib the same way I included the Facebook library to my project (which is oddly better documented for Android Studio than GooglePlay is) but it still looks like i'm missing something.
To do so, I've copied the whole folder <android-sdk>\extras\google\google_play_services\libproject\google-play-services_lib
to my <project-path>\libraries\google-play-services_lib
Then in Studio, i tried to add the copied folder in Module > add > Import module, like said in the Facebook documentation or in the link provided. I must be forgetting something like a gradle file, checking a module property, i don't really know anymore what i'm doing with this lib.
EDIT: I AM alreay working on Android Studio.
The google-services. json file is generally placed in the app/ directory (at the root of the Android Studio app module).
Google Play services powers a broad set of SDKs on Android to help you build your app, enhance privacy and security, engage users, and grow your business. These SDKs are unique in that they only require a thin client library to be included in your app, as shown in figure 1.
Using Android Studio, the only thing you need is to edit the build.gradle file and make sure that there are no android or google jar libraries, which means that you will need to remove jar libraries from your project (unless you're using libs like ActionbarSherlock which may need jar libs).
If you plan using Google Play Services, your build.gradle file should look like this :
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.android.support:support-v13:13.0.+'
compile 'com.google.android.gms:play-services:3.1.36'
}
Pretty straightforward indeed.
Also, if you're using Facebook SDK
, you will need to edit its build.gradle
file and change its dependencies in accordance to your main project's build.gradle
.
There are two steps to setting this up in Android Studio with Gradle.
1) Install the required parts of the SDK.
Android Studio uses a different Android SDK location to Eclipse, so you will need to do this in Android Studio even if you previously did it for Eclipse (unless you update them to share the same SDK location).
From the Android Studio menu bar, open Tools -> Android -> SDK Manager
Under the Extras section, install these:
2) Add the Gradle dependencies.
Do this in the build.gradle
for your module (i.e. not the top level one for the overall Android Studio project):
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:support-v13:13.0.+'
compile 'com.google.android.gms:play-services:3.1.36'
}
This might not be the minimum set of instructions required, but it worked for me. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With