注意添加APP_ID

       <meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>

使用对应的AndroidInitialization方法

gpg-cpp-sdk/android/include/gpg/android_initialization.h

 /**
* @file gpg/android_initialization.h
*
* @brief Android specific initialization functions.
*/ #ifndef GPG_ANDROID_INITIALIZATION_H_
#define GPG_ANDROID_INITIALIZATION_H_ #ifndef __cplusplus
#error Header file supports C++ only
#endif // __cplusplus #include <android/native_activity.h>
#include <jni.h>
#include "gpg/common.h" // Forward declaration of android_app from android_native_app_glue.h.
struct android_app; namespace gpg { /**
* AndroidInitialization includes three initialization functions, exactly one of
* which must be called. In the case of a standard Java Activity, JNI_OnLoad
* should be used. In the case of a NativeActivity where JNI_OnLoad will not be
* called, either android_main or ANativeActivity_onCreate should be used.
* android_main is used when building a NativeActivity using
* android_native_app_glue.h. ANativeActivity_onCreate is used when building a
* NativeActivity using just native_activity.h. android_native_app_glue.h and
* native_activity.h are default Android headers.
*
* The appropriate initialization function must be called exactly once before
* any AndroidPlatformConfiguration instance methods are called, and it must be
* called before a GameServices object is instantiated. It is permitted to
* instantiate a AndroidPlatformConfiguration before one of the intialization
* calls (for example, if the configuration object has global scope), as long as
* no methods are called before the initialization call. These methods need be
* called only once in the lifetime of the calling program, not once per
* GameServices object created.
*/
struct GPG_EXPORT AndroidInitialization {
/**
* When using Play Game Services with a standard Java Activity, JNI_OnLoad
* should be called when the dynamic library's JNI_OnLoad is called.
*/
static void JNI_OnLoad(JavaVM *jvm); /**
* When using Play Game Services with a NativeActivity which is based on
* android_native_app_glue.h, android_main should be called during your
* activity's android_main, before any other Play Game Services calls.
*/
static void android_main(struct android_app *app); /**
* When using Play Game Services with a NativeActivity which is based on only
* native_activity.h, ANativeActivity_onCreate should be called during your
* activity's ANativeActivity_onCreate, before any other Play Game Services
* calls.
*/
static void ANativeActivity_onCreate(ANativeActivity *native_activity,
void *savedState,
size_t savedStateSize);
}; } // namespace gpg #endif // GPG_ANDROID_INITIALIZATION_H_

API Level 14以上: OnActivityResult必须调用, 其他不需要.  14以下都需要.

gpg-cpp-sdk/android/include/gpg/android_support.h

 #ifndef __cplusplus
#error Header file supports C++ only
#endif // __cplusplus #include "gpg/common.h" namespace gpg { /**
* Functions which enable pre- Android 4.0 support.
*
* <h1>Android Lifecycle Callbacks</h1>
*
* For apps which target Android 2.3 or 3.x devices (API Version prior to 14),
* Play Game Services has no way to automatically receive Activity lifecycle
* callbacks. In these cases, Play Game Services relies on the owning Activity
* to notify it of lifecycle events. Any Activity which owns a GameServices
* object should call the AndroidSupport::* functions from within their own
* lifecycle callback functions. The arguments in these functions match those
* provided by Android, so no additional processing is necessary.
*
* For apps which target android 4.0+ (API Version greater than or equal to 14),
* most of these function calls are unnecessary. For such apps only the
* OnActivityResult function must be called.
...

Update: IAP/Google IAB

ref: http://developer.android.com/google/play/billing/billing_testing.html

遇到的问题:

response code 4: item unavailable

"the item you requested is not available for purchase"

http://developer.android.com/google/play/billing/v2/billing_reference.html

RESULT_ITEM_UNAVAILABLE    4

Indicates that Google Play cannot find the requested item in the application's product list. This can happen if the product ID is misspelled in your REQUEST_PURCHASE request or if an item is unpublished in the application's product list.

Check list: (answered by nmw01223)

http://stackoverflow.com/questions/11020587/in-app-billing-item-requested-not-available-for-purchase

对照检查, 我这里的问题是第6条:

dev console上上传的的APK, versionCode为6, 设备测试用的APK, versionCode 12.

将本地设备使用的版本号改为6, 问题解决. 估计将新版本的APK上传到dev console也可以解决这个问题.

[工作积累] Google Play Services的更多相关文章

  1. [工作积累] Google/Amazon平台的各种坑

    所谓坑, 就是文档中没有标明的特别需要处理的细节, 工作中会被无故的卡住各种令人恼火的问题. 包括系统级的bug和没有文档化的限制. 继Android的各种坑后, 现在做Amazon平台, 遇到的坑很 ...

  2. [工作积累] Google Play Game SDK details

    https://developers.google.com/games/services/cpp/api/structgpg_1_1AndroidSupport For apps which targ ...

  3. unity3d 导入google play services插件工程

    最近在给unity工程尝试接入google play services插件,遇到了些问题,记录一下. 之前在做android插件的时候,都是自己创建一个android工程,把生成的.class文件打包 ...

  4. [工作积累] android 中添加libssl和libcurl

    1. libssl https://github.com/guardianproject/openssl-android 然后执行ndk-build 2.libcurl 源代码组织结构, 下面的mak ...

  5. [工作积累] 32bit to 64bit: array index underflow

    先贴一段C++标准(ISO/IEC 14882:2003): 5.2.1 Subscripting: 1 A postfix expression followed by an expression ...

  6. [工作积累] bitfield

    ISO/IEC 14882:2003: 9.6 Bit-fields [class.bit] A member-declarator of the form identifieropt : const ...

  7. [工作积累] GCC 4.6 new[] operator内存对齐的BUG

    对于用户没有定义dctor(包括其所有成员)的类来说, new CLASS[n] 可能会直接请求sizeof(CLASS)*n的空间. 而带有dctor的 类, 因为delete[]的时候要逐个调用析 ...

  8. [工作积累] UE4 并行渲染的同步 - Sync between FParallelCommandListSet & FRHICommandListImmediate calls

    UE4 的渲染分为两个模式1.编辑器是同步绘制的 2.游戏里是FParallelCommandListSet并行派发的. mesh渲染也分两类,static mesh 使用TStaticMeshDra ...

  9. [工作积累] D3D10+ 中 Pixel Shader 的input semantic和参数顺序

    由于semantic的使用,我们有理由相信 vertex shader的output 和 pixel shader的input是按照semantic来匹配的,而跟传入顺序无关.印象dx9时代是这样. ...

随机推荐

  1. DAY2练习-购物车

    print('欢迎访问购物车')money = int(input('为方便购物,请输入您的总资产:')) #输入金钱必须为数字类型shopping_price_list = [{"name ...

  2. jsapi 调起微信支付的的踩坑

    问题: 公众微信号调起微信支付的时候,有的时候调起支付成功,有的时候调起支付失败.利用抓包工具抓取数据显示授权和调用后台的微信预支付订单接口都成功并且都返回正确的数据.但是调起支付的时候传入的data ...

  3. 如何用jmeter进行数据库性能测试

    由于业务需要,需要进行数据库性能测试,记录过程进行学习 测试前期准备: 1.测试点准备及需求点 a.性能测试目的 b.jmeter测试数据库基本脚本  get c.数据库性能监控工具选择 d.服务器性 ...

  4. 初读"Thinking in Java"读书笔记之第八章 --- 多态

    再论向上转型 在某些方法中,仅接收基类作为参数,而不是特殊的导出类,会使得程序更容易扩展. 转机 方法调用绑定 前期绑定(编译期绑定):在编译期将一个方法调用和方法主体关联起来. 后期绑定(动态绑定或 ...

  5. Problem C: 平面上的点和线——Point类、Line类 (III)

    Description 在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定,两点确定一条线段.现在我们封装一个“Point类”和“Line类”来实现平面上的点的操作. 根据“append ...

  6. vue项目中,使用vue-awesome-swiper插件实现轮播图

    一.安装 npm install vue-awesome-swiper 二.项目中引入 import 'swiper/dist/css/swiper.css'import {swiper,swiper ...

  7. gulp的使用(一)之gulp的基础了解

    Gulp是一个工具.用于项目构建. Gulp简介: 多个开发者共同开发一个项目,每位开发者负责不同的模块,这就会造成一个完整的项目实际上是由许多的“代码版段”组成的: 使用less.sass等一些预处 ...

  8. PHP 位运算

    $a & $b    a,b二进制后,取得每对应为都有1的部分,然后再转换为十进制 $a | $b      a,b二进制后,取得每对应为只要有1的部分,然后再转换为十进制 $a >&g ...

  9. 搭建QT环境

    开始使用QT时,环境配置好了,以后才不会有这方面的麻烦,所以第一步,把自己的工作环境搭建好! 下面是我的环境搭建过程,留个记录,也为了后来者能少走一些弯路. 注:本人的系统是WIN7x64位的,其他系 ...

  10. CentOS下将php和mysql命令加入到环境变量中-简单

    开发过程中.需要使用到php命令执行程序.但是php命令没有在全局命令中:每次执行都需要加上全路径特别麻烦,把php命令添加到全局变量中,以后每次只用输入php可以了 例: php -v  或 mys ...