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

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.

Related

Can't find google-play-services version that corresponds to firebase-messaging version

From what I understand, in order to use firebase messaging I need my google-play-services version to match my firebase-messaging version in my app's build.gradle. According to Google's Firebase setup guide the firebase version I should use is 17.3.0, so I figure I'm supposed to use google-play-services version 17.3.0, but that doesn't work because Android Studio can't find that version:
Here is how I've added them to app/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.google.android.gms:play-services:17.3.0'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
implementation "com.android.support:support-v4:24.1.1+"
// SUB-PROJECT DEPENDENCIES END
}
What am I doing wrong here?
From what I understand, in order to use firebase messaging I need my
google-play-services version to match my firebase-messaging version
That is no longer true, google recently changed to semantic versioning so libraries are no longer tied to the same version. 12.0.1 I believe was the last version that you could make the same version for everything play services related and everything else must follow the new versioning system
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
You can check googles maven repository for the latest version of any library
https://dl.google.com/dl/android/maven2/index.html
Also you should not include all of google play services in your project and you should only declare the libraries you need as this makes your app smaller.

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'

What's the dependency for GcmTaskService (GCM)?

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

Google game services using gradle

Is there a way to add google game services in a simple way using gradle 0.5+ like how its possible with the support library or the google play services:
dependencies {
compile "com.android.support:support-v4:13.0.0"
compile 'com.google.android.gms:play-services:3.1.36'
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
}
Play Game Services is not a separate library from the Google Play Services library. It seems that you are using a very old version of play-services through. Try the newest version, which definitely has the Games API:
compile 'com.google.android.gms:play-services:6.5.87'

How to import Google API in Android Studio

I'm trying out Android Studio. I want to use Drive API in my project. In eclipse, there is a Google Plugin for Eclipse, but how about Android Studio? Does anyone tried it so far?
Bellow you can find last versions for Google Drive (2014.12.28):
//Google Drive API
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.google.api-client:google-api-client-xml:1.18.0-rc'
compile 'com.google.http-client:google-http-client-gson:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.apis:google-api-services-drive:v2-rev155-1.19.0'
To check last version try following links:
https://developer.android.com/google/play-services/setup.html
https://code.google.com/p/google-api-java-client
https://developers.google.com/api-client-library/java/apis/drive/v2
http://mvnrepository.com/artifact/com.google.apis/google-api-services-drive
I was in the same situation and had to find here an there information on how Gradle works to find the right set of dependencies and exclude needed.
Here the lines needed in the dependencies of your build.gradle file
// Replace 'dependencies' in your build.gradle file with the following
// or add these to whatever other dependencies you have.
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
}
As they keep changing in time, I've made a gist that I'll keep updated as things changes.
I've wrote an article to modify the Google Drive Quick Start to make it work with Android Studio; if interested you can find it here
EDIT: This Gradle Imports are to use the Google Drive API for Java, not the Developer Preview Google Drive API integrated with the Google Play Services.
The Java client library supports Android, as well. You can download it here: https://code.google.com/p/google-api-java-client/wiki/APIs#Drive_API
Then, unzip the Drive SDK download and move the folder into the libs section of your Project. For example:
/Users/-username-/AndroidStudioProjects/MyProject/MyProjectActivity/libs/
At this point, you can add the library to your project by clicking File -> Project Structure, and then clicking the Libraries tab, and the + sign to add the SDK into your project.
You can read the Android-specific development instructions for the Google API Client Library for Java here: https://code.google.com/p/google-api-java-client/wiki/Android
Did you try
Go to Project Structure > Global Libraries / Libraries > Link to the jar of the API you need in the SDK folder
Link the library with your module
I haven't tried google driver, but I tried google usb accessory api. In my case
Open MyProject/MyProject/build.gradle
add
compile files("libs/usb.jar")
to the dependencies block
Of course, copy the google driver libs from
android-studio\sdk\add-ons\addon-google_apis-google-10\libs\usb.jar
to MyProject/MyProject/libs
Good luck to you.
smokybob's answer worked but then I did some experiments and this also worked for me.
dependencies {
compile files ('libs/libGoogleAnalyticsServices.jar')
compile ('joda-time:joda-time:2.3')
compile ('com.google.code.gson:gson:2.2.4')
compile 'com.google.android.gms:play-services:4.1.+'
}
I am guessing the joda-time and Gson have nothing to do with the drive API.
Note when I do a
gradle dependancies
I get
+--- joda-time:joda-time:2.3
+--- com.google.code.gson:gson:2.2.4
\--- com.google.android.gms:play-services:4.1.+ -> 4.1.32
\--- com.android.support:support-v4:19.0.1
From the Extra's under the SDK manager, I downloaded Google Play Services, Google Repository and Android Support Library. Thereafter, I included dependency as below, sync'd with Gradle and was able to access the APIs.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Pls. install or update the Google Repository through the SDK manager to use this dependency.
compile 'com.google.android.gms:play-services:5.0.+'
}

Categories

Resources