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:
Related
Background info
When uploading an app to the play store that uses a native library its necessary to also upload the native debug symbols to get useful crash/ANR info.
If you upload without symbols you receive the following warning: "This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug."
In the past when uploading apps as .apk files it was necessary to manually upload such debug info. Now using .aab if the native library is built via android studio its possible to set android.defaultConfig.ndk.debugSymbolLevel = 'FULL' at which point when you build a the .aab it will include the debug info automatically, you upload this single file and everything is done/working.
pre-built libraries
However its not always possible/ideal/necessary to build a library inside android studio. Sometimes there are reasons for libraries to be externally pre-built and just used by android studio not built by it; Android studio supports this via a directory structure which is described here https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs
In short you just copy the libraries into the correct src/main/jniLibs/{ABI} path(s) and it is picked up and made part of the bundle.
Problem
Android studio can build a .aab that contains debug info that play store can understand so that you don't need to upload it manually.
Android studio can use pre built native libraries if you place them in the right path structure
I am unable to find any documentation or way to do both of these things together, use native pre-built libraries but include their debug info in the .aab. Even though logically it should be possible to do this.
I have searched everywhere I think but can't find anyone even talking about this really, how/where do you place the corresponding debug information so that that also can be included as part of the .aab? Is there a separate path for this, do they just need a specific file extension, does gradle need to be told what to do with them somehow?
Is it really just not possible?
Things I have tried:
Don't split the debug info just leave them in the .so files - play store does not strip them then so you deliver giant debug versions of your builds to your users
Split the debug info into files with .so.dbg extension and place them alongside the .so files - they aren't included in the .aab
Following the instructions (here https://support.google.com/googleplay/android-developer/answer/9848633 and elsewhere) to manually zip and upload the symbols after uploading the .aab - this appears to work but isn't the same convenience wise as having them in the .aab
I've tried building a sample app with android studio building a lib instead of using a pre-built lib just to verify that it does then include the debug info and what file extension it uses.
After some more digging I found the task responsible for this is "ExtractNativeDebugMetadataTask" with which some effort can likely be tailored/altered to do custom things here.
However this ended up being unnecessary as while digging into this I discovered that it actually already works.
At least as of now in latest gradle versions (not sure about the past).
It was only failing due to some NDK path confusion which doesn't fail the build/creation of the bundle building but just logs an easy to miss informational message.
Ultimately all you need to do to make this work is:
Build your external .so files with -g -g3 or similar
Do not strip them in any way
Place them in jniLibs directory structure un-stripped
Configure your build.gradle appropriately android{ ndk { debugSymbolLevel 'FULL' } ndkPath "$projectDir/path/to/NDK" }
Resulting .aab will contain the stripped .so files and the split-debug .so.dbg files all in the right location.
when building .ane files, you should be careful about naming your resources so no two extensions would conflict each other when used in one app. I know that and it's ok.
I have another kind of conflict problem! you see, in one of the extensions I've been building, I used the external .jar file, Google play services and the extension works like charm. everything was fine until the day that I created another extension which was happened to use the external jar file, Google Play Services again!
when building .ane files, I actually merge any needed external .jar files into the one that I have exported myself from eclipse.
now that I have two different extensions both happen to be using Google Play services external .jar file, when I use them in one app, it won't allow me to package my .apk
the error message says:
java.lang.IllegalArgumentException: already added:
com/google/android/gms/appstate/OnStateListLoadedListener;
at
com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
how can we bypass this kind of confliction?!
Extension's will not allow same method name's even they are in different extensions. i think that is the mistake you did in making extension's. please look at them and changes method names it will work.
In order to integate my app with GDrive I have followed the tutorial on https://developers.google.com/drive/quickstart-android
In step 3 of the tutorial, the tutorial recommends to install the Google Eclipse plugin to take care of the library setup (this plugin let's you choose which's Google API's to use and creates the /libs folder including the jars for you).
The tutorial shows how to take a picture and upload it to Google Drive.
After working through the tutorial I decided to extend the example: since my app works with Google Spreadsheets I added the spreadsheets API (using the Google Eclipse Plugin) to the example.
The application compiles but on run-time I do get the following error:
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Ljavax/annotation/CheckForNull;
My feeling is that some libraries are conflicting, but these libraries are all calculated using the Google Eclipse plugin? How is this possible and how should I resolve this issue?
My (generatd) libs folder looks like this (contains the Google Drive API v2 and Spreadsheets API):
gdata-client-1.0.jar
gdata-spreadsheet-3.0.jar
gdata-spreadsheet-meta-3.0.jar
google-api-client-1.12.0-beta.jar
google-api-client-android-1.12.0-beta.jar
google-api-services-drive-v2-rev55-1.12.0-beta.jar
google-collect-1.0-rc1.jar
google-http-client-1.12.0-beta.jar
google-http-client-android-1.12.0-beta.jar
google-http-client-gson-1.12.0-beta.jar
google-http-client-jackson-1.12.0-beta.jar
google-http-client-jackson2-1.12.0-beta.jar
google-oauth-client-1.12.0-beta.jar
gson-2.1.jar
guava-jdk5-13.0.jar
jackson-core-2.0.5.jar
jackson-core-asl-1.9.9.jar
jsr305-1.3.9.jar
jsr305.jar
Thanks for any help,
Peter
I had the same problem. Removing the jsr305.jar from the libs folder solved the problem for me.
Remove the bin and gen folders and Build the project
or
check multiple private libraries added to your project
or
check whether the multiple play services added to your project
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.
As far as I understand, all the built-in standard apps like (email, music, calendar etc) are built using the same API. So I should be able to import a project like mail / music etc without checking out the full source repository of android. I'v been trying that but I am getting compilation problems like class resolve failure.
Am I doing it wrong? Do I have to get the full android source project to import a project like Mail ?
These apps are open source (mail, music and calendar). But they depend on internal classes and resources and can't be compiled with the SDK
You could pull a Git clone of some particular app. For example - the EMail app from
https://android.googlesource.com/platform/packages/apps/Email/
The first problem is that Google are using MK files for building inside their android projects and Eclipse do not use them. But you can compile it because you have the sources, the XML resources and the manifest also.
The second problem is to deal with the dependencies. For example the gallery app may depend on few camera classes. You can manually copy them to your project.
Other way is:
Using Eclipse for writing code and testing if it builds correctly and using GNU Make 3.82 from http://www.gnu.org tool that will build the supplied Android.MK file and run the app.