Include Google Play Services jar as part of the project? - android

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.

Related

Add Google Play Services to Native Extension for Adobe AIR Android

Okay, I would like to know if anyone managed to pull this thing of? I am making native extension and my native JAR uses Google Play Services via reflection. I have added Google Play Services library to my native extension, here's how platform.xml looks like:
<platform xmlns="http://ns.adobe.com/air/extension/3.1">
<packagedDependencies>
<packagedDependency>android-support-v4.jar</packagedDependency>
<packagedDependency>google-play-services.jar</packagedDependency>
</packagedDependencies>
<packagedResources>
<packagedResource>
<packageName>com.google.android.gms</packageName>
<folderName>google-play-services-res</folderName>
</packagedResource>
</packagedResources>
</platform>
My android build folder has structure like this:
android
- nativeLib.jar
- android-support-v4.jar
- google-play-services-res (folder)
- google-play-services.jar
- library.swf
When I build my ANE w/o Google Play Services library (which has around 5.1 mb), I see that my ANE has for example 800 kb. After adding Google Play Services dependency like this, ANE has around 6 mb which for me indicates that these JARs stated in platform.xml are somehow bundled in native extension. Now, my native JAR has some function where I can see if calling method from Google Play Services library fails or not. It always fails when I call it from AIR Android app I made and where I integrated this generated ANE.
So, my native JAR and google-play-services JAR are standing next to each other before packing them in my ANE, but after triggering method from my native jar, it turns out that it isn't aware that google-play-services.jar is anywhere around.
Just for the record, I don't have any issues in bridging AIR with native library, all calls are working properly and interface I am exposing to ActionScript files is fully functional, it's just that native library is performing certain actions depending on wether Google Play Services are found or not and in my case -> they are never found.
Any ideas what I may be doing wrong and how to pull this thing of?
Thanks in advance.
You could just use this ANE:
https://github.com/distriqt/ANE-GooglePlayServices
We've packaged both those libraries and resources in that ?
I managed to get Google Play Services working (with just the necessary JAR files) using this code:
https://github.com/Oldes/ANEAmanitaAndroid-public/tree/GooglePlay
You can see what I did to have it working from the minimal "hello" ANE using this pull request details:
https://github.com/Oldes/ANEAmanitaAndroid-public/pull/1
I've got the GPS jar files from SDK extracting them from AAR archives like:
extras\google\m2repository\com\google\android\gms\play-services-base\9.4.0\play-services-base-9.4.0.aar
In each aar (which is just a zip) file is classes.jar which I just copy and rename as play-services-base-9.4.0.jar in my project.
Also to have the GPS running correctly, you must specify correct application ID in the app manifest like at this line:

Extract play-services-ads jar from google-play-services 6.5+

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.

Android Studio Gradle Library setup

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?

Why do android docs want me to import play services as a project and not as a lib?

I am going to use Google Play Services in my android application. I have no problem there, however I do have a theoretical question...
In the Google docs for the API it says you must import the Project source from the SDK, and not the *.Jar file as a lib (Google Play Services setup docs).
This is fine, but I find it more natural to just add a reference to the *.jar file in there.
My question therefore is: Is there a reason Google says we must do this? if not I'd rather just reference the *.jar file.
Thanks, Jason
Google Play Service contains resources (layout, images, etc.) that cannot be included in a jar file. This is linked to the way the framework compute all the XML resources of your project to give them unique IDs.
This is why you have to import a library project instead of simply including a jar dependency.

Share code between client and server side

I'm developing an Android app with Play framework as backend. There are some classes that are common between the client and server side projects.
If I create a library project or a shared folder in Eclipse, and link the classes to both projects, Play complains that it cannot find the classes, (maybe because it has to be in a folder called 'app'?)
Is it possible to share code between client and server side projects using Play framework?
I don't know the Play framework, but if you create a library in Eclipse, instead of linking to it in the build path you must add it as a library in the android settings of your project. (You find them by selecting your project and pressing alt+enter)
Play uses his own classloader and classpath. So you must put your classes into a jar and this into the lib. Or you create a module for the shared code.
What I ended up doing was link the 'app' folder and specify an inclusion pattern for the shared package.
the problem with jar is that the server needs to be restarted everytime it changes, the source needs to be repackaged and the project needs to be re-eclipsified. As for the library project, i'm not using any android specific code in the shared folders
The way to do it would be:
Create a new project with the code to share. This should provide an API to do what you want to do.
Build the project as a JAR
Link the Jar on PLay (drop it on lib folder) and Android

Categories

Resources