android - 最新的 Google 服务 (v. 21) ANE + AIRMobile native 扩展解析界面失败

标签 android mobile google-play-services air-native-extension

我正在尝试通过创建 native 扩展来向 Air 移动应用添加最新的 Google Plus (google-play-services.jar) 支持。 代码没有编译时错误或警告,JAR 导出正常,ANE 构建并包含在项目中没有问题, 但是当我运行我的 apk 时,它崩溃了。在 device-crush-logs 中我可以看到以下错误:

12-04 11:08:18.602 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.602 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed

起初,我尝试自己从空项目构建扩展。 之后我在github上找到了一个开源扩展 github.com/alextel69/google-play-game-services-ane/ 我构建了该扩展并包含在我的 AIR 移动项目中,它工作正常,但 google-play-services.jar 太旧了,不包含我需要的类, 所以我尝试将其 libs/google-play-services.jarlibs/android-support-v4.jar 替换为我在 Android SDK 中获得的最新版本经理。 这导致了上述错误。 这样,我没有修改任何一行代码,或者ANT的build.xml,或者其他任何东西,我只是切换了旧的 android-support-v4.jar + google-play-services .jar(工作正常!)与较新的 android-support-v4.jar + google-play-services.jar(失败)。我的意思是 ANE 构建得很好,甚至创建了扩展,并且它的一些方法可以工作并返回值,但是当我引用 google-service 代码时,我得到了那个奇怪的错误。

尽管新旧 JAR 中的接口(interface)似乎是相同的:dl.dropboxusercontent.com/u/13839683/ane/jars_compare.png

顺便说一句,这些错误似乎仅出现在 AIR mobile 中。使用这些 android-support-v4.jar + google-play-services.jar 的纯 native 应用程序没有问题。

这是我的 native 扩展的简要方案: dl.dropboxusercontent.com/u/13839683/ane/scheme.png

这是从扩展程序诞生到崩溃的完整设备日志:

12-04 11:08:18.602 23195 23195 I ~ANE~   : ------------- INITIALIZE MY EXTENSION -------------
12-04 11:08:18.602 23195 23195 I ~ANE~   : ------------- CREATE MY EXTENSION -------------
12-04 11:08:18.602 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.602 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.602 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.602 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.602 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.onStop, referenced from method com.google.api.games.Context.dispose
12-04 11:08:18.602 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6754: Lcom/google/example/games/basegameutils/GameHelper;.onStop ()V
12-04 11:08:18.602 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-04 11:08:18.602 23195 23195 W dalvikvm: VFY: unable to resolve static field 2701 (Leaderboards) in Lcom/google/android/gms/games/Games;
12-04 11:08:18.602 23195 23195 D dalvikvm: VFY: replacing opcode 0x62 at 0x0000
12-04 11:08:18.612 23195 23195 W dalvikvm: VFY: unable to resolve static field 2700 (Achievements) in Lcom/google/android/gms/games/Games;
12-04 11:08:18.612 23195 23195 D dalvikvm: VFY: replacing opcode 0x62 at 0x0000
12-04 11:08:18.612 23195 23195 W dalvikvm: VFY: unable to resolve static field 2700 (Achievements) in Lcom/google/android/gms/games/Games;
12-04 11:08:18.612 23195 23195 D dalvikvm: VFY: replacing opcode 0x62 at 0x0000
12-04 11:08:18.612 23195 23195 W dalvikvm: VFY: unable to resolve static field 2700 (Achievements) in Lcom/google/android/gms/games/Games;
12-04 11:08:18.612 23195 23195 D dalvikvm: VFY: replacing opcode 0x62 at 0x0000
12-04 11:08:18.612 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.612 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.612 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.612 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.612 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.beginUserInitiatedSignIn, referenced from method com.google.api.games.Context$beginUserInitiatedSignIn.call
12-04 11:08:18.612 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6715: Lcom/google/example/games/basegameutils/GameHelper;.beginUserInitiatedSignIn ()V
12-04 11:08:18.612 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0009
12-04 11:08:18.612 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.612 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.612 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.612 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.612 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.signOut, referenced from method com.google.api.games.Context$signOut.call
12-04 11:08:18.612 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6767: Lcom/google/example/games/basegameutils/GameHelper;.signOut ()V
12-04 11:08:18.612 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0009
12-04 11:08:18.612 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.612 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.612 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.612 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.622 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.isSignedIn, referenced from method com.google.api.games.Context$isSignedIn.call
12-04 11:08:18.622 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6740: Lcom/google/example/games/basegameutils/GameHelper;.isSignedIn ()Z
12-04 11:08:18.622 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x000a
12-04 11:08:18.622 23195 23195 I ~ANE~   : Context :: testANE.call
12-04 11:08:18.622 23195 23195 I ~ANE~   : Context :: promptUserToSignInOnStartup.call
12-04 11:08:18.622 23195 23195 I ~ANE~~  : Context :: Extension.autoSignIn = true
12-04 11:08:18.622 23195 23195 I ~ANE~   : Context :: start.call
12-04 11:08:18.622 23195 23195 I ~ANE~~  : Context :: start.call[END]
12-04 11:08:18.622   480 26966 I ActivityManager: START u0 {cmp=air.com.sq.kitchen/com.google.api.games.SignInActivity} from pid 23195
12-04 11:08:18.712 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6728: Lcom/google/example/games/basegameutils/GameHelper;.getInvitationId ()Ljava/lang/String;
12-04 11:08:18.712 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-04 11:08:18.712 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.712 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.712 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.712 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.712 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.getSignInError, referenced from method com.google.example.games.basegameutils.BaseGameActivity.getSignInError
12-04 11:08:18.712 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6731: Lcom/google/example/games/basegameutils/GameHelper;.getSignInError ()Lcom/google/example/games/basegameutils/GameHelper$SignInFailureReason;
12-04 11:08:18.712 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-04 11:08:18.732 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.732 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.742 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.742 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.762 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-04 11:08:18.762 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.762 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.762 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.762 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.762 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.makeSimpleDialog, referenced from method com.google.example.games.basegameutils.BaseGameActivity.showAlert
12-04 11:08:18.762 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6746: Lcom/google/example/games/basegameutils/GameHelper;.makeSimpleDialog (Ljava/lang/String;Ljava/lang/String;)Landroid/app/Dialog;
12-04 11:08:18.762 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-04 11:08:18.762 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.762 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.762 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.762 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.762 23195 23195 I dalvikvm: Could not find method com.google.example.games.basegameutils.GameHelper.signOut, referenced from method com.google.example.games.basegameutils.BaseGameActivity.signOut
12-04 11:08:18.762 23195 23195 W dalvikvm: VFY: unable to resolve virtual method 6767: Lcom/google/example/games/basegameutils/GameHelper;.signOut ()V
12-04 11:08:18.762 23195 23195 D dalvikvm: VFY: replacing opcode 0x6e at 0x0002
12-04 11:08:18.762 23195 23195 I dalvikvm: Failed resolving Lcom/google/example/games/basegameutils/GameHelper; interface 940 'Lcom/google/android/gms/common/api/GoogleApiClient$ConnectionCallbacks;'
12-04 11:08:18.762 23195 23195 W dalvikvm: Link of class 'Lcom/google/example/games/basegameutils/GameHelper;' failed
12-04 11:08:18.762 23195 23195 D dalvikvm: DexOpt: unable to opt direct call 0x1a39 at 0x08 in Lcom/google/example/games/basegameutils/BaseGameActivity;.getGameHelper
12-04 11:08:18.762 23195 23195 I ~ANE~   : SignInActivity :: onCreate
12-04 11:08:18.762 23195 23195 D AndroidRuntime: Shutting down VM
12-04 11:08:18.762 23195 23195 W dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416dbba8)
12-04 11:08:18.762 23195 23195 E AndroidRuntime: FATAL EXCEPTION: main
12-04 11:08:18.762 23195 23195 E AndroidRuntime: Process: air.com.sq.kitchen, PID: 23195
12-04 11:08:18.762 23195 23195 E AndroidRuntime: java.lang.NoClassDefFoundError: com.google.example.games.basegameutils.GameHelper
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at com.google.example.games.basegameutils.BaseGameActivity.getGameHelper(Unknown Source)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at com.google.example.games.basegameutils.BaseGameActivity.onCreate(Unknown Source)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at com.google.api.games.SignInActivity.onCreate(Unknown Source)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:5231)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:136)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5001)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at java.lang.reflect.Method.invokeNative(Native Method)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Method.java:515)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
12-04 11:08:18.762 23195 23195 E AndroidRuntime:        at dalvik.system.NativeStart.main(Native Method)
12-04 11:08:18.782   480 14720 W ActivityManager:   Force finishing activity air.com.sq.kitchen/com.google.api.games.SignInActivity
12-04 11:08:18.782   480 14720 W ActivityManager:   Force finishing activity air.com.sq.kitchen/.AppEntry

inb4


我非常彻底地发现了这个问题,并发现了几个相似的线程,但没有一个能解决我的问题

1) Google plus ane air native extension failed resolving interface的解

jar xf /path-to-play-services-project/libs/google-play-services.jar

jar uf ./my_gplus_extension.jar ./com

没有解决任何问题。

2) 任何使用 Eclipse 的操作 Adobe Air 4.0 Native Extension with Google Play Services也没有帮助(毕竟,我正在使用 ANT 构建 JAR)。

3) 当切换到新的 google-service-library 时,我会修改资源 (\google-play-services_lib\res*.*)。

4) 我什至尝试扩展谷歌的界面并修改我的 GameHelper 来实现它们,但这也没有帮助 (dl.dropboxusercontent.com/u/13839683/ane/extend_interface.jpg) .

最佳答案

我设法部分解决了这个问题。我问the same question on starling-forum其成员 tsangwailam 建议我将 AIR SDK 中的 dx.jar 替换为 Android SDK 中的新 dx.jar。

替换 dx.jar 确实有帮助。我将 %ANDROID_SKD%\sdk\build-tools\19.1.0\lib\dx.jar 复制到 %FLEXSDK%\lib\android\bin\dx.jar 中强> 并且扩展程序开始正常工作!

但是...

一旦我运行 Activity SingInActivity

Intent intent = new Intent(context.getActivity().getApplicationContext(), SingInActivity.class); context.getActivity().startActivity(intent);

我的应用程序变得不活动 - 无法处理触摸。 似乎出现了一些不可见的模式弹出窗口,并且不允许我的应用程序捕获点击。 最小化并恢复我的应用程序后,我看到 SingInActivity 进入方法“protected void onStart()”,并且我知道我的应用程序“看到”它,因为我使用 FREContext.dispatchStatusEventAsync() 将其记录到 Flash 的文本字段中,但应用程序仍然没有能够处理用户输入(原生 flash 和 starling/stage3d TouchEvents) 这是一个有趣的事实,当我的 AIR 应用程序失去处理触摸的能力时,Android 的导航按钮会从隐藏的点变成实际的按钮: https://dl.dropboxusercontent.com/u/13839683/ane/untouchable.png

至于设备日志,我没有看到任何错误或 Java 异常,或者没有任何东西(至少对我来说)可以解释这种行为。

那它可能是什么?也许我还需要替换一些其他 JAR?

关于android - 最新的 Google 服务 (v. 21) ANE + AIRMobile native 扩展解析界面失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27295409/

相关文章:

android - ConstraintLayout — 垂直限制 View 的顶部

html - 按钮在移动设备上不起作用

jquery - 通过 jQuery Mobile 使用 Devise 登录

android - Lint 提示没有翻译 gcm_defaultSenderId 字符串

android - 下载文件时如何设置手机内存路径?

Android 应用程序链接多个 Intent 过滤器主机和 list 合并不起作用

android - 约束布局内的回收器 View 问题

javascript - jquery mobile 阻止执行或退出

android - 造型 OssLicensesMenuActivity

android - Google Play 控制台 - 无法编辑草稿