我想构建一个插件来为 Unity 包装最新的 Google Cloud Messaging API (GCM)。我编写了 Java 代码来执行此操作,并将 GCM 插件包含到我的 gradle 构建中:
compile 'com.google.android.gms:play-services-gcm:7.5.0'
Run Code Online (Sandbox Code Playgroud)
由于目标是 Unity,我需要创建一个 AAR 或 JAR + 资源以包含在 Assets/Plugins/Android 中,并且它们需要包含所有传递依赖项(包括 appcompat 和播放服务本身)。如果我使用 Unity 的 AAR 编译应用程序,我会得到:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GooglePlayServicesUtil;
Run Code Online (Sandbox Code Playgroud)
这是正常的,因为 AAR 不包含依赖的 Google Play 类。而且我找不到 GCM 模块的独立 JAR。我迷路了,我需要什么才能获得捆绑了所有依赖项的 AAR/JAR?
提前致谢!