在cordova android应用程序中从javascript调用新的PayPalPaymentDetails()时出现java错误

Posted

技术标签:

【中文标题】在cordova android应用程序中从javascript调用新的PayPalPaymentDetails()时出现java错误【英文标题】:Getting java error while invoking new PayPalPaymentDetails() from javascript in cordova android app 【发布时间】:2015-01-20 15:23:25 【问题描述】:

我按照https://github.com/paypal/PayPal-Cordova-Plugin中提到的步骤操作。

将https://github.com/paypal/PayPal-android-SDK/tree/master/libs 的内容添加到我的项目库文件夹中。 并成功构建。

当我点击支付按钮时,eclipse的logCat控制台出现以下错误

11-22 20:32:54.778: I/dalvikvm(9132): Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.paypal.android.sdk.bs.a
11-22 20:32:54.778: W/dalvikvm(9132): VFY: unable to resolve static method 692: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
11-22 20:32:54.778: D/dalvikvm(9132): VFY: replacing opcode 0x71 at 0x0006
11-22 20:32:54.798: D/AndroidRuntime(9132): Shutting down VM
11-22 20:32:54.798: W/dalvikvm(9132): threadid=1: thread exiting with uncaught exception (group=0x4157dba8)
11-22 20:32:54.798: E/AndroidRuntime(9132): FATAL EXCEPTION: main
11-22 20:32:54.798: E/AndroidRuntime(9132): Process: com.hello.app, PID: 9132
11-22 20:32:54.798: E/AndroidRuntime(9132): java.lang.RuntimeException: Unable to bind to service com.paypal.android.sdk.payments.PayPalService@41fd4068 with Intent  cmp=com.hello.app/com.paypal.android.sdk.payments.PayPalService (has extras) : java.lang.RuntimeException: Service extras required. Please see the docs.
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.app.ActivityThread.handleBindService(ActivityThread.java:2597)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.app.ActivityThread.access$1900(ActivityThread.java:135)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.os.Handler.dispatchMessage(Handler.java:102)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.os.Looper.loop(Looper.java:136)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.app.ActivityThread.main(ActivityThread.java:5001)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at java.lang.reflect.Method.invokeNative(Native Method)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at java.lang.reflect.Method.invoke(Method.java:515)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at dalvik.system.NativeStart.main(Native Method)
11-22 20:32:54.798: E/AndroidRuntime(9132): Caused by: java.lang.RuntimeException: Service extras required. Please see the docs.
11-22 20:32:54.798: E/AndroidRuntime(9132):     at com.paypal.android.sdk.payments.PayPalService.a(Unknown Source)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at com.paypal.android.sdk.payments.PayPalService.onBind(Unknown Source)
11-22 20:32:54.798: E/AndroidRuntime(9132):     at android.app.ActivityThread.handleBindService(ActivityThread.java:2584)
11-22 20:32:54.798: E/AndroidRuntime(9132):     ... 10 more
11-22 20:32:54.869: D/dalvikvm(9132): GC_FOR_ALLOC freed 725K, 26% free 10873K/14600K, paused 31ms, total 31ms
11-22 20:32:54.989: D/dalvikvm(9132): GC_FOR_ALLOC freed 499K, 25% free 11004K/14600K, paused 23ms, total 23ms
11-22 20:32:56.180: D/dalvikvm(9132): GC_FOR_ALLOC freed 641K, 25% free 11039K/14600K, paused 20ms, total 20ms

我正在使用 PayPalAndroidSDK-2.7.1。 注意:ios cordova 应用的集成成功。

【问题讨论】:

【参考方案1】:

当我们不执行我错过的 PayPalMobile.init() 时,就会出现这些错误。现在一切正常。

【讨论】:

以上是关于在cordova android应用程序中从javascript调用新的PayPalPaymentDetails()时出现java错误的主要内容,如果未能解决你的问题,请参考以下文章

使用外部 Java 插件在 PhoneGap/Cordova 中捕获音频/视频

如何在 Cordova 中从 CDVPlugin 显示 ViewController?

如何在带有 cordova 的 iOS 设备中从 iCloud 读取文件?

有啥方法可以在 Linux/AIX 中从 ksh 更改进程名称?

Web 应用程序/Cordova 不支持 android 的哪些功能?

在 iOS 模拟器中从 firebase 推送通知