6

I want to build a plugin for wrapping the latest Google Cloud Messaging API (GCM) for Unity. I wrote Java code to do it and included the GCM plugin to my gradle build:

compile 'com.google.android.gms:play-services-gcm:7.5.0'

Since the target is Unity I need to create either an AAR or a JAR + resources to be included in Assets/Plugins/Android, and they need to include all transitive dependencies (including appcompat and the play services themselves). If I compile the app with my AAR from Unity, I get:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GooglePlayServicesUtil;

Which is normal since the AAR doesn't contain the dependent Google Play classes. And I can't find a standalone JAR for the GCM modules. I'm lost, what do I need to get an AAR/JAR with all dependencies bundled?

Thanks in advance!

Randy Levy
  • 22,566
  • 4
  • 68
  • 94
Brunni
  • 143
  • 1
  • 11
  • Check out this link : http://stackoverflow.com/questions/16682847/how-to-manually-include-external-aar-package-using-new-gradle-android-build-syst – NovusMobile Jul 15 '15 at 05:30
  • 1
    Thank you, unfortunately this does not solve the problem. It seems impossible to include the contents of the external AAR in an Android Library. My solution was to put all AAR files (which I found in the maven repo -- a copy can be downloaded locally under android-sdk/extras/m2repository) under Plugins/Android. – Brunni Jul 22 '15 at 17:38
  • Did you find the solution? – Vladimir Fisher Jul 07 '20 at 09:56

1 Answers1

0

Afaik you need to remove libs/classes.jar from your plugin .aar and add the dependencies as .aar again. There is the Unity Jar Resolver that might be helpful (and also pointing to repositories for the dependencies u need)

kemuri
  • 478
  • 4
  • 9