Android In App结算失败,回复码为6

时间:2018-07-17 17:34:41

标签: android in-app-purchase google-play-services in-app-billing

我正在使用googlesamples中提供的Billing Manager来处理我的android应用中的应用购买。一切正常,直到我单击购买并收到错误消息:

交易无法完成。

从日志中,我可以看到我从服务器返回了响应代码6(“ API操作期间出现致命错误”)。另外,我在购买过程中会看到两个可疑错误:

E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
    at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15168)
    at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2492)
    at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:688)
    at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
    at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
    at android.os.Binder.execTransact(Binder.java:404)
    at dalvik.system.NativeStart.run(Native Method)

E/Parcel: Class not found when unmarshalling: com.google.android.finsky.billing.common.PurchaseParams
java.lang.ClassNotFoundException: com.google.android.finsky.billing.common.PurchaseParams
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:251)
    at java.lang.Class.forName(Class.java:216)
    at android.os.Parcel.readParcelableCreator(Parcel.java:2140)
    at android.os.Parcel.readParcelable(Parcel.java:2104)
    at android.os.Parcel.readValue(Parcel.java:2020)
    at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)
    at android.os.Bundle.unparcel(Bundle.java:249)
    at android.os.Bundle.getString(Bundle.java:1118)
    at android.content.Intent.getStringExtra(Intent.java:5151)
    at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1468)
    at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1063)
    at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:4385)
    at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:254)
    at com.android.server.am.ActivityManagerService.startActivityIntentSender(ActivityManagerService.java:4266)
    at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:260)
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2712)
    at android.os.Binder.execTransact(Binder.java:404)
    at dalvik.system.NativeStart.run(Native Method)
 Caused by: java.lang.NoClassDefFoundError: com/google/android/finsky/billing/common/PurchaseParams
    at java.lang.Class.classForName(Native Method) 
    at java.lang.Class.forName(Class.java:251) 
    at java.lang.Class.forName(Class.java:216) 
    at android.os.Parcel.readParcelableCreator(Parcel.java:2140) 
    at android.os.Parcel.readParcelable(Parcel.java:2104) 
    at android.os.Parcel.readValue(Parcel.java:2020) 
    at android.os.Parcel.readArrayMapInternal(Parcel.java:2321) 
    at android.os.Bundle.unparcel(Bundle.java:249) 
    at android.os.Bundle.getString(Bundle.java:1118) 
    at android.content.Intent.getStringExtra(Intent.java:5151) 
    at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1468) 
    at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1063) 
    at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:4385) 
    at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:254) 
    at com.android.server.am.ActivityManagerService.startActivityIntentSender(ActivityManagerService.java:4266) 
    at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:260) 
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2712) 
    at android.os.Binder.execTransact(Binder.java:404) 
    at dalvik.system.NativeStart.run(Native Method) 
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.finsky.billing.common.PurchaseParams" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at java.lang.Class.classForName(Native Method) 
    at java.lang.Class.forName(Class.java:251) 
    at java.lang.Class.forName(Class.java:216) 
    at android.os.Parcel.readParcelableCreator(Parcel.java:2140) 
    at android.os.Parcel.readParcelable(Parcel.java:2104) 
    at android.os.Parcel.readValue(Parcel.java:2020) 
    at android.os.Parcel.readArrayMapInternal(Parcel.java:2321) 
    at android.os.Bundle.unparcel(Bundle.java:249) 
    at android.os.Bundle.getString(Bundle.java:1118) 
    at android.content.Intent.getStringExtra(Intent.java:5151) 
    at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1468) 
    at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1063) 
    at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:4385) 
    at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:254) 
    at com.android.server.am.ActivityManagerService.startActivityIntentSender(ActivityManagerService.java:4266) 
    at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:260) 
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2712) 
    at android.os.Binder.execTransact(Binder.java:404) 
    at dalvik.system.NativeStart.run(Native Method) 

但是,我不确定错误和购买失败之间是否存在关联。 知道我哪里出错了吗?

1 个答案:

答案 0 :(得分:0)

尝试通过以下github论坛解决方案: Fixed bug w/ null vs. empty payload

  

此请求请求中提出的更改:

     
      
  • 将空有效负载提升为string.Empty以防止两者混淆。空的有效负载字符串反序列化为null导致它   好像购买失败了。
  •   
  • 提早初始化tcsPurchase以防止可能出现的竞争情况。
  •   

首先提到了该错误,here