1

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.

uerceg
  • 4,637
  • 6
  • 45
  • 63

2 Answers2

1

You could just use this ANE:

https://github.com/distriqt/ANE-GooglePlayServices

We've packaged both those libraries and resources in that ?

Michael
  • 3,776
  • 1
  • 16
  • 27
  • Thanks for the link, I wasn't able to locate this repository in my searches, weird. :/ Anyhow, at the end I ended up wrapping google-play-services.jar into ANE with (at the moment) no ActionScript interface at all, because for my particular case I don't need any. I will stick with mine implementation because I just need some parts of Google Play Services library and with https://gist.github.com/dmarcato/d7c91b94214acd936e42 I leave in library only things I need thus causing resulting ANE to be 2.6M instead of 10.7M like in your project. I will eventually post answer how I did it. – uerceg Aug 21 '15 at 07:15
  • 1
    Also just wanted to note that stripping out the other libraries can be problematic if you intend on using other ANE's . So just take care if you are using any other Google related ANE's – Michael Aug 23 '15 at 06:50
  • @Michael How do I use your **.ane** file in place of google-play-services.jar? – IgorGanapolsky Aug 22 '16 at 20:06
  • Hi, Our Google Play Services ANEs simply wrap the appropriate jars and resources from the play services libraries. So if you are making an ANE build against a version of the play services library however don't package them with your ANE, but instead include our ANEs. Let me know if that doesn't make sense. – Michael Aug 22 '16 at 23:49
1

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:

Oldes
  • 937
  • 1
  • 9
  • 24