最新的Google服务(第21版)ANE + AIRMobile原生扩展无法解析界面

时间:2014-12-04 13:35:28

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

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

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 太旧了,不包含我需要的类, 所以我试图用我在Android SDK中获得的最新版本替换它的 libs / google-play-services.jar libs / android-support-v4.jar 经理。 这导致了上述错误。 通过这种方式,我没有修改单个代码行,或ANT的build.xml,或其他任何东西,我只是改变旧的 android-support-v4.jar + google-play-services .jar (工作正常!)较新的 android-support-v4.jar + google-play-services.jar (失败)。我的意思是ANE构建得很好,即使扩展已经创建,其中一些方法可以工作并返回值,但是当我参考谷歌服务代码时,我得到了那个奇怪的错误。

虽然旧JAR和新JAR中的接口似乎相同: dl.dropboxusercontent.com/u/13839683/ane/jars_compare.png

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

以下是我原生扩展的简要方案: 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

1 个答案:

答案 0 :(得分:2)

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

取代dx.jar确实有帮助。我拿了%ANDROID_SKD%\ sdk \ build-tools \ 19.1.0 \ lib \ dx.jar 并将其复制到%FLEXSDK%\ lib \ android \ bin \ dx.jar 并且扩展开始正常工作了!

但是...

一旦我开展活动SingInActivity

  

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

我的应用程序变为非活动状态 - 无法处理触摸。 看起来似乎出现了一些看不见的模态弹出窗口并且确实允许我的应用程序捕获水龙头。 在最小化和恢复我的应用程序后,我看到SingInActivity步入mehtod" protected void onStart()"我知道我的应用程序"看到"它,因为我使用FREContext.dispatchStatusEventAsync()将其记录到我的Flash文本域中,但是应用程序仍然无法处理用户输入(本机flash和starling / stage3d TouchEvents) 这是一个有趣的事实,当我的AIR应用程序失去处理触摸的能力时,android的导航按钮会从隐藏的点转变为实际的按钮: https://dl.dropboxusercontent.com/u/13839683/ane/untouchable.png

对于设备日志,我没有看到任何错误或Java ecxeptions,或者没有(至少对我而言)可以解释这种行为。

那又怎样呢?也许我需要替换一些其他JAR?