What's the dependency for GcmTaskService (GCM)? - android

What dependency can I put in my build.gradle file so that I can use Google's GcmTaskService (and/or other GCM features)?
I would prefer to use the specific dependency and not to use the generic Google Play Services dependency: compile 'com.google.android.gms:play-services:7.5.0'

Found the answer I was looking for: compile 'com.google.android.gms:play-services-gcm:7.5.0'
Source that includes all the different specific Google Play Services packages: https://developers.google.com/android/guides/setup

Related

Does "play-services:9.8.0" include "play-services-location:9.8.0"?

I am upgrading an App, and in my build.gradle file, I have this:
dependencies {
..........
compile 'com.google.android.gms:play-services:9.8.0'
..........
}
In the Android SDK Setup Quickstart Guide Urban Airship provides, they offer this as a sample code:
dependencies {
..........
// Recommended for location services
compile 'com.google.android.gms:play-services-location:9.8.0'
..........
}
If I use "play-services:9.8.0" I would assume it would also include "play-services-location:9.8.0" because "play-services-location:9.8.0" should be a subset of "play-services:9.8.0", but I wanted to confirm. Do you know if this is a correct assumption? Thank you.
From Google Api Documentation
you can use the latest Google play service api:
dependencies {
compile 'com.google.android.gms:play-services:10.2.1'
}
If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.
To Selectively compiling APIs into your executable:
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-plus:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-games:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
the detail lists are provided in the documentation.
Yes, play-services is the full bundle. They were broken apart to reduce the method count of your app so you don't hit the dex limit. More information can be found here.

How do I identify and import only specific libraries from Google Play Services?

I currently have the following line in my dependency:
compile 'com.google.android.gms:play-services:4.2.42'
I put this in longn back when I was just starting out to code my app and now I realize that this is what is probably causing my app to bloat at about 20 MB
Is there a way to identify and specifically import only necessary services to reduce my app size? I am pretty sure there are ways to import only specific modules, but also pointers on how I can identify which modules I need will be appreciated
From version 6.5, you can instead selectively compile Google Play service APIs into your app,
For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
please check this link
First, you need to check your project & identify which Play Services Modules are used. Then, You can selectively add the play services APIs which are necessary to your project.
For Ex : The below will be add Google Analytics and Maps modules to your app.
dependencies {
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
}
You can use something like this
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'

How to compile only the needed Google Play Services' dependencies with Ant

Seems that with newer versions of Google Play you can compile only needed modules with gradle
with something like
dependencies {
compile 'com.google.android.gms:play-services-base:6.5.+'
compile 'com.google.android.gms:play-services-maps:6.5.+'
}
If I want to include only some dependencies (needed to analytics and in app billing services) without gradle using standard project.properties file, How could I achieve the same result?
This is not possible with what Google provides. Split dependencies are only supported with Gradle.

which Google Play services API contains com.google.android.gms.appstate.AppStateManager?

I am using google play services API, and from old version of code, i included the whole library. Now i want to use Selectively compiling APIs from this link https://developers.google.com/android/guides/setup. But i can't find what does com.google.android.gms.appstate.AppStateManager come from .
I already have this
compile 'com.google.android.gms:play-services-base:7.5.0'
compile 'com.google.android.gms:play-services-identity:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-games:7.5.0'
compile 'com.google.android.gms:play-services-plus:7.5.0'
but none of them have.
Please help.
The AppStateManager of the Google Play Services is DEPRECATED, so they have hidden the AppState play-services-dependency.
At the moment you can still get it via the following dependency, but it will probably get deleted soon.
compile 'com.google.android.gms:play-services-appstate:7.8.0'
or for Updated version use
implementation 'com.google.android.gms:play-services-appstate:8.4.0'
Add the following dependency in build.gradle rember this is for old DEPRECATED
compile 'com.google.android.gms:play-services-appstate:9.0.0'
This is work for me

Execution failed for task ':packageAllDebugClassesForMultiDex'

I am try to use the new android multidex support for a project. I have some problem with this exception:
Error:Execution failed for task ':shineV3:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command$1.class
about the problem. I use 2 different jar package as dependency, and some class will be duplicated in classes.dex because both jars contains they. any idea?
thanks in Advance
For those that are coming into this, I figured out why this was happening. For me it was that I was compiling the Google Analytics V2 jar as well as the full play services. Google allows you to break down what play services you really need for you app and compile those individual items. Check them out here. I excluded the Google Play Analytics which is on V4 right now and it worked
If you are integrating Google Analytics V2 and Google play services in your app, then you need to do the following in your gradle file:
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/libGoogleAnalyticsServices.jar')
}
It worked for me. Hope it will work for others too. :)
adding this to your grdale compile "com.google.android.gms:play-services:7.5.+" means adding all play services including analytics, maps, vcm .. etc. you can add
as guides mentions:
In versions of Google Play services prior to 6.5, you had to compile
the entire package of APIs into your app. In some cases, doing so made
it more difficult to keep the number of methods in your app (including
framework APIs, library methods, and your own code) under the 65,536
limit.
From version 6.5, you can instead selectively compile Google Play
service APIs into your app. For example, to include only the Google
Fit and Android Wear APIs, replace the following line in your
build.gradle file:
compile 'com.google.android.gms:play-services:7.5.0' with these lines:
compile 'com.google.android.gms:play-services-fitness:7.5.0' compile
'com.google.android.gms:play-services-wearable:7.5.0'
https://developers.google.com/android/guides/setup

Categories

Resources