在应用程序计费中ServiceConnection未初始化

时间:2015-03-03 10:53:13

标签: android in-app-purchase

我已在我的应用程序中实施了In app purchase。我已经按照给定网址的所有步骤进行操作。

http://developer.android.com/google/play/billing/billing_integrate.html

当我运行我的代码时,我在mServiceConn中得到了空指针异常。我有debuge代码,发现永远不会调用onServiceConnected(),所以不建立serviceconnection。

任何人都可以帮我吗?

1 个答案:

答案 0 :(得分:0)

在尝试找到合适解决方案的几个小时内,同样的问题让我意外地解决了这个问题。在此之后我成功完成了测试购买:

    本指南的
  1. 设置GoogleApiClient - https://developer.android.com/google/auth/api-client.html。 我使用此客户端设置从Google Plus服务获取Google帐户ID:

        mGoogleApiClient = new GoogleApiClient.Builder(mContext)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_PROFILE)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    
  2. 手动安装并重新安装后 Google Plus服务 - https://play.google.com/store/apps/details?id=com.google.android.gms

  3. 重新发布apk in beta chanel

  4. 最后通过 Google+社区

  5. 为我的第二个帐户设置 Beta测试人员的访问权限