注意添加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. pip install beautifulsoup4.失败

    在学习python爬虫时,用到bs4解析网页,开始遇到安装bs出错 Collecting beautifulsoup4Exception:Traceback (most recent call las ...

  2. PAT B1020

    PAT B1020 解决思路 :贪心法,每次选取单价最高的月饼. 先上一个自己错误的解法 #include <cstdio> #include <algorithm> usin ...

  3. Python基础(条件判断,循环,占位符等)

    Python 自动化 系统开发用的语言和自动化脚本可以不同 学习peython可用于: 网路爬虫,数据分,web开发,人工智能,自动化运维,自动化测试,嵌入式,黑客 第三方库比较全 脚本语言:功能单一 ...

  4. SharePoint Framework 在web部件中使用已存在的JavaScript库 - 捆绑打包和外部引用

    博客地址:http://blog.csdn.net/FoxDave 在构建SPFx客户端web部件时,你可以使用公网已有的JavaScript库来构建强大的解决方案.但是在使用的时候你需要考虑你引用的 ...

  5. Ubuntu 16.04 上安装 MySQL 5.7 教程

    介绍 MySQL 是一种开源数据库管理系统,通常作为流行的LAMP(Linux,Apache,MySQL,PHP / Python / Perl)堆栈的一部分安装.它使用关系数据库和SQL(结构化查询 ...

  6. day16 面向对象二

    类的成员之变量 1. 实例变量. 对象.xxx = xxx 2. 类变量. 直接写在类中的变量就是类变量. 类变量一般用类名来访问. 对象中共性的属性提取出来. 例: class A: a = 1 # ...

  7. Date对象方法

    创建Date               new  Date() Date对象方法: get系列: getDate()            返回一个月中的某一天(1-31) getDay()    ...

  8. 2018-4-25 初识html

    第一天 简单了解web 路线 html css js 发布网站 web运作 html html是超文本语言,也就是标记语言.说白了也就规定了一些符号,然后赋予这些符号意义.比如规定a就是超链接标签,用 ...

  9. learn-ES6基础语法1-let&const

    1.let ① 使用let声明的变量,所声明的变量只能在命令所在的代码块内有效. 同样在代码块内的a和c,c在代码块内就可以输出,a在代码块外就找不到了. ② 使用let命令声明的变量在域解析的时候不 ...

  10. mybatis 源码分析二

    1.SqlSession下的四大对象 Executor.StatementHandler.ParameterHandler.ResultSetHandler StatementHandler的作用是使 ...