Google Play services 4.2 has now been rolled out to the world, and it’s packed with much-anticipated
features such as the brand new Cast API and the updated Drive API.

In this post, we’ll take a look at the new Google Play services client APIs and what they mean for your apps — for details be sure to read Accessing Google Play services and the API reference documentation.
To install the Google Play services SDK for development:

Launch the SDK Manager in one of the following ways:

In Android Studio, click SDK Manager undefined in the toolbar.

Install the Google Play services SDK
Scroll to the bottom of the package list, expand Extras, select Google Play services, and install it.
If you’re using Android Studio, also install Google Repository (it provides the Maven repository used for Gradle builds).


Google Play Service & Google Repository Install Screen

The Google Play services SDK is saved in your Android SDK environment at
C:Program FilesAndroidandroid-studiosdkextrasgoogle.


Google Play service SDK path for local Disk(C)

Install a compatible version of the Google APIs platform
If you want to test your app on the emulator, expand the directory for Android 4.2.2 (API 17) or a higher version, select Google APIs, and install it. Then create a new AVD with Google APIs as the platform target.


Google APIs Screen for Android4.22(API version 17)

Now we are ready to start using Google Play Service In android studio application development. For using Google Play Service in your apps simple flowing this next steep:
Using Google Play Service in Gradle Build Application
Import your project in the android studio. I will show you using google play service Gradle build project. here in this project you should see the new Gradle build project structure


Build Gradle PhoneGap Project in android studio structure

Library Project:  1. /lib/ add here Google Play service jar file. copy google-play-service.jar file here from 

C:Program FilesAndroidandroid-studiosdkextrasgooglegoogle_play_serviceslibprojectgoogle-play-services_liblibs

 . in here see the image in option 1 lib section.
Save the changes and click Sync Project with Gradle Files in the toolbar.

Now open the build.gradle file inside your application module directory.
See Image 3 Options build.gradle.
Add a new build rule under dependencies for the latest version of play services. For example


build.gradle file dependencies rule adding line

Be sure you update this version number each time Google Play services is updated. for better when you add this line see your downloaded version then add this Like: com.google.android.gms:play-service:your-version-number
Save the changes and click Sync Project with Gradle Files in the toolbar.

Open your app’s manifest file and add the following tag as a child of the element:

Now need to prevent proguard exception from stripping away required classes,

Open Proguard-rule.tex file See android studio structure Image 4 Number Option and now add the following lines in the Proguard-rule

-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

If all steep are successfully done than your project has able to use google play service .if you have any trouble in applying this, please write a comment here I will try to solve your problem.

Leave a Reply

avatar
  Subscribe  
Notify of