Question:
How to extract play-services-ads.jar from google-play-services.jar ?
Background:
Since last update of google play services we may not include whole lib in our project when we need only one part of it source. The problem is that i cant add google-play-services.jar as library dependency in my project, it can be done only as file dependency. So i need somehow add only play-services-ads.jar, not the whole google-play-services.jar to avoid library method limit 65,536.
Using Android Studio, you can take advantage of the split Google Play Services libraries, ensuring you only include the part of Google Play Services necessary for what you need.
In your case, you will need to include the following AARs from AndroidSDK\extras\google\m2repository:
* com.google.android.gms:play-services-ads:6.5.87
* com.google.android.gms:play-services-base:6.5.87
And the following AARs from AndroidSDK\extras\android\m2repository:
* com.android.support:support-v4:21.0.3
Note that these are AARs and not JARs.
Related
From where to download the google-play-services aar files for version 11.6.0 OR above 11.0.4
I know just by adding the dependency in apps build.gradle adds the library in it.
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-ads:11.6.0'
This is fair in case of Android Studio.
But as a Unity Developer, I have downloaded the Google Mobile Ads Unity Plugin which after import gives the play services ads, lite, basement, gass of version 11.6.0
Now we have some location dependency in our project. So I have downloaded the Android SDK and its stored in this path.
/Users/USERNAME/Library/Android/sdk
After navigating to /Users/USERNAME/Library/Android/sdk/extras/google/m2repository/com/google/android/gms,
I got the latest play services library of version 11.0.4 only and if I tried to create a Android Studio project by adding GPS dependency of 11.6.0, its getting added properly.
So my question is,
where google play services library of version 11.6.0 is downloaded. So that I can go to that location and get all the aar file needed for my Unity Project
Following are the details from Android developer documentation:
Programmatic access:
For programmatic access to Google's Maven artifacts, you can get an XML list of artifact groups from maven.google.com/master-index.xml (link) which gives the group path
Then, for any group, you can view its library names and versions at:
maven.google.com/group_path/group-index.xml
For example, libraries in the android.arch.lifecycle group are listed at maven.google.com/android/arch/lifecycle/group-index.xml (link).
You can also download the POM and JAR files at:
maven.google.com/group_path/library/version/library-version.ext
For example:
maven.google.com/android/arch/lifecycle/compiler/1.0.0/compiler-1.0.0.pom. (link)
For more details please refer:
https://developer.android.com/studio/build/dependencies.html#gmaven-access
For complete list of Google Play Services libraries, refer below xml:
https://dl.google.com/dl/android/maven2/com/google/android/gms/group-index.xml
Eg: To download Google Play Services Location library AAR file, use the following link:
https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-location/11.6.0/play-services-location-11.6.0.aar
You can replace group name, version, file, extension to download other files.
Note: Do check the pom file for each module, it may have dependencies on other Google Play Services libraries. If so, you will need to download all dependent files.
[Update]:
You can use Google's Unity Jar Resolver for this:
https://github.com/googlesamples/unity-jar-resolver
Check the links below:
play-services-ads-11.6.0
play-services-location-11.6.0
You can find and download all versions of the aar libraries at the MVN repository.
Also:
I came across a github project for Titanium/Appcelerator/AxWay. It has a script that downloads the latest play-services libraries.
The project is at: https://github.com/appcelerator-modules/ti.playservices
The relevant script is: updater/index.js
Hopefully the script will not go away because it is very useful.
If you find yourself writing a big Android application that depends on many different libraries (which I would recommend instead of reinventing the wheel) it is very likely that you have already come across the 65k method limit of the Dalvik executable file classes.dex. Furthermore, if you depend on large libraries like the Google Play Services SDK which itself in already contained more than 20k methods in version 5.0 you are forced to use tricks like stripping packages or multidex support to avoid errors while packaging. With Android's new runtime ART which is publicly available since Android Lollipop multiple dex files are easier to handle, but currently developers are still forced to do method counting.
What is the simplest way to reduce your application`s method count while using Google Play Services?
The biggest change for developers that came with the 6.5 release of the Google Play Services was probably the Granular Dependency Management. Google managed to split up it's library to allow developers to depend only on certain components which they really need for their apps.
Since version 6.5 developers are no longer forced to implement the complete Google Play Services library in their app, but can selectively depend on components like this:
compile 'com.google.android.gms:play-services-fitness:6.5.+'
compile 'com.google.android.gms:play-services-wearable:6.5.+'
compile 'com.gogole.android.gms:play-services-maps:6.5.+'
...
If you want to compile the complete library into your app, you can still do so:
compile 'com.google.android.gms:play-services:6.5.+'
A complete list of available packages can be found on the Android Developers site.
For someone who do not use Android Studio w/gradle or don't want to implement ProGuard to you project.
It's possible to avoid 65k while using google-play-services
by keeping some packages that you really want to use by using jarjar. For example, in my project I want to implement only google map and google location I lean my google-play-services.jar like this.
Download jarjar HERE
Create new file call 'services.rules'
edit it as follow
keep com.google.android.gms.maps.*
keep com.google.android.gms.location.*
Copy your original google-play-services.jar / jarjar-1.4.jar / services.rules into the same folder
start command prompt and type..
java -jar jarjar-1.4.jar process services.rules google-play-services.jar google-lean.jar
That's it you will get a new .jar that size was reduce a lot (method also)
use it instaed of google-play-services.jar and dex over 56k will gone.
Here is .jar that was lean already as mention above.
I know this question is old but for those of you who face this issue while working on eclipse and cannot use the above answer
please follow the steps
if you don't want to download android studio to get the lib projects
you can download lib files from here
https://www.dropbox.com/s/1pf73czcn7pyqgi/com.google.android.gms.rar?dl=0
and skip to step 4
1 - first of all you still need android studio to download your dependencies
you can download it from here
https://developer.android.com/sdk/index.html
2 - then in your build.gradle inside your app add the below lines
dependencies {
compile 'com.google.android.gms:play-services-maps:7.5.0'
//map , gcm or any specific api for a hole list visit the below link
//https://developers.google.com/android/guides/setup
}
and then hit sync project with gradle file
after that you will get to lib projects
play-services-base
play-services-maps
right click on them to get their path
4 - create project inside eclipse delete the generate files inside src folder
, res folder and manifest
5- copy res and manifest from play-services-base to your project
6 - copy file inside play-services-base/jars to the libs folder of your project
normally named classes.jar (please rename it to any other name so it won't conflict with other project)
7- add this jar to build paths then right click on project / properties / java build path / order and export tab check the added jar
8- right click on project / properties / android / check is lib
9- make the same steps for play-services-maps
10 - now you got to lib projects one is called googleBase and the other is called googleMaps (or any other name)
11 - add them to your project as libraries
now add the following lines to your manifest
<!-- Include required permissions for Google Maps API to run-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="" />
for a complete tutorial with images please refer to below link
http://androidninja.quora.com/Prevent-65-K-Methods-Count-When-Using-Google-Lib-on-Android-with-eclipse-adt
I've been struggling with getting external libraries to work properly. When you import a library, it gets copied into the project's directory structure. I'd like to avoid this as I have libraries I use in many projects, and these libraries get updated on a fairly frequent basis.
So these are the libraries I'm trying to get setup right now:
aal - This is a general use library that I use across several applications. This android library has no external dependencies.
aal_amazon - This is a library for accessing Amazon specific APIs. This library depends on aal, and has the Amazon game circle SDK in it.
aal_google - This library is for google APIs. This library depends on google play services, and also aal.
Ideally, I'd like to be able to set a project's dependency to either aal_amazon, or aal_google, and by extension, the project should have access to aal.
I know you can use project(':aal').projectDir = new File('path/to/file') to set the library's folder location, however I seem to be having the issue because the amazon, and google libs have their own dependencies.
Is there a way to set things up so in a project, I just put this in the settings.gradle:
include ':app'
include ':aal_amazon'
project(':aal_amazon').projectDir= new File('/path/to/aal_amazon')
Where the above would give the project access to aal_amazon, AND aal?
I would like to integrate my app with a variety of file storage services. I followed the quickstart instructions for the Drive sdk, which adds a bunch of jars to my projects libs directory. Additionally, the Dropbox sdk requires the following list of jars:
commons-logging-1.1.1.jar
dropbox-android-sdk-1.5.3.jar
httpclient-4.0.3.jar
httpcore-4.0.1.jar
httpmime-4.0.3.jar
json-simple-1.1.jar
Once all of these are added to my project, I get the following error when I try to run:
Dex Loader] Unable to execute dex: Multiple dex files define
Lorg/apache/http/entity/mime/FormBodyPart;
If I remove the httpmime jar added for Dropbox, my project runs fine. But is this a safe way to resolve the conflict? Is there an alternative method with which I can build my project and include all the required jars?
Assuming no version conflicts this would work fine. Compare the httpmime-4.0.3.jar to the httpmime jar that Drive added to your libs directory. If they're the same, then it's fine. If they're different, then you'll have to find out the differences between the two and insure that they're not breaking changes. As a last resort you could also repackage one of the SDKs with its required version of httpmime in a jar selectively obfuscated with ProGuard, though that's a hassle.
If you are developing with Eclipse, consider using Google Plugin for Eclipse. It provides a way to add any of the Google's SDK to your app. All the jars are added automatically.
Is it possible/recommended to include the Google Play Services jar file as part of your android project vs. including it as the dependent library?
This page http://developer.android.com/google/play-services/setup.html asks you to include the Google Play Services as part of the dependent library. But for simplification purpose, I was thinking of including the jar as part of the android project itself.
Anyone has done this successfully?
Library project contains string resources. They are not included in jar file. However if you copy XML file also it will be probably working fine.