Commit 0a575261cf755765592ec41f538775edfeff8b10
1 parent
7aca13ff87
Exists in
master
v4.2.1:clear for bluePay
Showing 6 changed files with 2 additions and 2 deletions Inline Diff
GameSDK-ND-release4.2.0.aar
No preview for this file type
GameSDK-ND-release4.2.1.aar
No preview for this file type
GameSDKDemo/build.gradle
1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
2 | 2 | ||
3 | repositories{ | 3 | repositories{ |
4 | flatDir{ | 4 | flatDir{ |
5 | dirs 'libs' | 5 | dirs 'libs' |
6 | } | 6 | } |
7 | } | 7 | } |
8 | 8 | ||
9 | android { | 9 | android { |
10 | compileSdkVersion 22 | 10 | compileSdkVersion 22 |
11 | buildToolsVersion "25.0.0" | 11 | buildToolsVersion "25.0.0" |
12 | 12 | ||
13 | defaultConfig { | 13 | defaultConfig { |
14 | minSdkVersion 9 | 14 | minSdkVersion 9 |
15 | targetSdkVersion 22 | 15 | targetSdkVersion 22 |
16 | versionCode 1000002 | 16 | versionCode 1000002 |
17 | versionName "1.0.2" | 17 | versionName "1.0.2" |
18 | } | 18 | } |
19 | 19 | ||
20 | buildTypes { | 20 | buildTypes { |
21 | release { | 21 | release { |
22 | minifyEnabled false | 22 | minifyEnabled false |
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
24 | } | 24 | } |
25 | } | 25 | } |
26 | lintOptions{ | 26 | lintOptions{ |
27 | abortOnError false | 27 | abortOnError false |
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | dependencies { | 31 | dependencies { |
32 | compile fileTree(dir: 'libs', include: ['*.jar']) | 32 | compile fileTree(dir: 'libs', include: ['*.jar']) |
33 | testCompile 'junit:junit:4.12' | 33 | testCompile 'junit:junit:4.12' |
34 | compile 'com.android.support:appcompat-v7:22.2.0' | 34 | compile 'com.android.support:appcompat-v7:22.2.0' |
35 | // compile project(':GameSDK') | 35 | // compile project(':GameSDK') |
36 | compile(name:'GameSDK-ND-release4.2.0',ext:'aar') | 36 | compile(name:'GameSDK-ND-release4.2.1',ext:'aar') |
37 | } | 37 | } |
38 | 38 |
GameSDKDemo/libs/GameSDK-ND-release4.2.0.aar
No preview for this file type
GameSDKDemo/libs/GameSDK-ND-release4.2.1.aar
No preview for this file type
IntegrationGuide.md
1 | # Gump SDK 4 in new domain for Android接入文档 | 1 | # Gump SDK 4 in new domain for Android接入文档 |
2 | 2 | ||
3 | V4.2.0 | 3 | V4.2.0 |
4 | 2017年4月26日 | 4 | 2017年4月26日 |
5 | 5 | ||
6 | ## 版本概述 | 6 | ## 版本概述 |
7 | 7 | ||
8 | 此版本为使用AndroidStudio开发的第一个版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. | 8 | 此版本为使用AndroidStudio开发的第一个版本,一改eclipse的工程依赖方式,使用aar的方式提供sdk接入包,除功能外,相对上一版本没有继承关系,请按此文档描述接入. |
9 | 9 | ||
10 | 此SDK适用android2.3以上系统. | 10 | 此SDK适用android2.3以上系统. |
11 | 11 | ||
12 | ## 第一章 接入指南 | 12 | ## 第一章 接入指南 |
13 | ### 1.依赖导入 | 13 | ### 1.依赖导入 |
14 | 将aar添加到libs目录下,然后配置gradle | 14 | 将aar添加到libs目录下,然后配置gradle |
15 | 以下为必须项 | 15 | 以下为必须项 |
16 | 16 | ||
17 | repositories{ | 17 | repositories{ |
18 | flatDir{ | 18 | flatDir{ |
19 | dirs 'libs' | 19 | dirs 'libs' |
20 | } | 20 | } |
21 | } | 21 | } |
22 | dependencies { | 22 | dependencies { |
23 | compile(name:'GameSDK-releaseXXX',ext:'aar') | 23 | compile(name:'GameSDK-releaseXXX',ext:'aar') |
24 | } | 24 | } |
25 | 25 | ||
26 | 26 | ||
27 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 | 27 | 可选接入vk登录时,需要导入vkLibrary工程,并配置模块依赖,如下 |
28 | 28 | ||
29 | compile project(':vksdk_library') | 29 | compile project(':vksdk_library') |
30 | 30 | ||
31 | ### 2.修改AndroidManifest.xml文件 | 31 | ### 2.修改AndroidManifest.xml文件 |
32 | 首先添加必要的权限,如下所示: | 32 | 首先添加必要的权限,如下所示: |
33 | 33 | ||
34 | <uses-permission android:name="android.permission.INTERNET" /> | 34 | <uses-permission android:name="android.permission.INTERNET" /> |
35 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 35 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
36 | <uses-permission android:name="android.permission.BLUETOOTH" /> | 36 | <uses-permission android:name="android.permission.BLUETOOTH" /> |
37 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | 37 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
38 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> | 38 | <uses-permission android:name="android.permission.WRITE_SETTINGS"/> |
39 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> | 39 | <uses-permission android:name="android.permission.GET_ACCOUNTS"/> |
40 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 40 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> |
41 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | 41 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> |
42 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | 42 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> |
43 | <uses-permission android:name="android.permission.SEND_SMS"/> | 43 | <uses-permission android:name="android.permission.SEND_SMS"/> |
44 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> | 44 | <!-- VERY IMPORTANT! Don't forget this permission, or in-app billing won't work. --> |
45 | <uses-permission android:name="com.android.vending.BILLING" /> | 45 | <uses-permission android:name="com.android.vending.BILLING" /> |
46 | 46 | ||
47 | 其次注册相应的Activity,具体如下: | 47 | 其次注册相应的Activity,具体如下: |
48 | 48 | ||
49 | <activity | 49 | <activity |
50 | android:name="com.g.root.ContainerActivity" | 50 | android:name="com.g.root.ContainerActivity" |
51 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 51 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
52 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" | 52 | android:windowSoftInputMode="stateAlwaysHidden|adjustPan" |
53 | android:launchMode="singleTask" | 53 | android:launchMode="singleTask" |
54 | android:theme="@style/Theme.TransparentWin" > | 54 | android:theme="@style/Theme.TransparentWin" > |
55 | </activity> | 55 | </activity> |
56 | <activity | 56 | <activity |
57 | android:name="com.g.root.PaymentActivity" | 57 | android:name="com.g.root.PaymentActivity" |
58 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 58 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
59 | android:launchMode="singleTask" | 59 | android:launchMode="singleTask" |
60 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > | 60 | android:theme="@android:style/Theme.Translucent.NoTitleBar" > |
61 | <intent-filter> | 61 | <intent-filter> |
62 | <category android:name="android.intent.category.DEFAULT" /> | 62 | <category android:name="android.intent.category.DEFAULT" /> |
63 | <action android:name="android.intent.action.VIEW" /> | 63 | <action android:name="android.intent.action.VIEW" /> |
64 | <category android:name="android.intent.category.BROWSABLE" /> | 64 | <category android:name="android.intent.category.BROWSABLE" /> |
65 | <data | 65 | <data |
66 | android:host="com.gump.sdk" | 66 | android:host="com.gump.sdk" |
67 | android:scheme="gump+游戏的appId" /> | 67 | android:scheme="gump+游戏的appId" /> |
68 | </intent-filter> | 68 | </intent-filter> |
69 | </activity> | 69 | </activity> |
70 | <activity | 70 | <activity |
71 | android:name="com.g.root.ExchangeWindow" | 71 | android:name="com.g.root.ExchangeWindow" |
72 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" | 72 | android:configChanges="orientation|screenSize|keyboardHidden|keyboard|screenLayout" |
73 | android:theme="@style/Theme.WinForExchange" > | 73 | android:theme="@style/Theme.WinForExchange" > |
74 | </activity> | 74 | </activity> |
75 | 75 | ||
76 | <service android:name="com.g.root.PushService" /> | 76 | <service android:name="com.g.root.PushService" /> |
77 | 77 | ||
78 | <!-- vk登录使用,若不接入vk,不需配置 --> | 78 | <!-- vk登录使用,若不接入vk,不需配置 --> |
79 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> | 79 | <activity android:name="com.vk.sdk.VKOpenAuthActivity" /> |
80 | <activity | 80 | <activity |
81 | android:name="com.vk.sdk.VKServiceActivity" | 81 | android:name="com.vk.sdk.VKServiceActivity" |
82 | android:label="ServiceActivity" | 82 | android:label="ServiceActivity" |
83 | android:theme="@style/VK.Transparent" /> | 83 | android:theme="@style/VK.Transparent" /> |
84 | 84 | ||
85 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 | 85 | ### 3.向Gump平台索要游戏ID(AppID),完成代码接入 |
86 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 | 86 | 正式开始接入逻辑代码前,先介绍下一些附加设置,以方便代码接入 |
87 | 87 | ||
88 | *是否打印debug日志 | 88 | *是否打印debug日志 |
89 | 89 | ||
90 | GumpSDK.getSettings().enableDebugLogging(true); | 90 | GumpSDK.getSettings().enableDebugLogging(true); |
91 | 91 | ||
92 | *Gump Logo隐藏 | 92 | *Gump Logo隐藏 |
93 | 93 | ||
94 | GumpSDK.getSettings().setLogoShow(false); | 94 | GumpSDK.getSettings().setLogoShow(false); |
95 | 95 | ||
96 | *横竖屏控制,默认为横屏,参数为false即为竖屏 | 96 | *横竖屏控制,默认为横屏,参数为false即为竖屏 |
97 | 97 | ||
98 | GumpSDK.getSettings().setScreenLandscape(true); | 98 | GumpSDK.getSettings().setScreenLandscape(true); |
99 | 99 | ||
100 | *设置是否启用Facebook登录和VK登录 | 100 | *设置是否启用Facebook登录和VK登录 |
101 | 101 | ||
102 | GumpSDK.getSettings().setFBEnable(true); | 102 | GumpSDK.getSettings().setFBEnable(true); |
103 | GumpSDK.getSettings().setVKEnable(true); | 103 | GumpSDK.getSettings().setVKEnable(true); |
104 | 104 | ||
105 | *设置是否启用GoogleD登录 | 105 | *设置是否启用GoogleD登录 |
106 | 106 | ||
107 | GumpSDk.getSettings().setGoogleEnable(true); | 107 | GumpSDk.getSettings().setGoogleEnable(true); |
108 | 108 | ||
109 | *若要使用V4版支付请设置 | 109 | *若要使用V4版支付请设置 |
110 | 110 | ||
111 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); | 111 | GumpSDK.getSettings().setPaymentVersion(PaymentVersion.V4); |
112 | 112 | ||
113 | #### 1.调用GumpSDK前需要执行初始化。 | 113 | #### 1.调用GumpSDK前需要执行初始化。 |
114 | 114 | ||
115 | 若不需要分渠道 | 115 | 若不需要分渠道 |
116 | 116 | ||
117 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); | 117 | GumpSDK.init(Context,Appid, Appkey,InitializeCallback); |
118 | 如果需要定义渠道,必须使用如下方法 | 118 | 如果需要定义渠道,必须使用如下方法 |
119 | 119 | ||
120 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); | 120 | GumpSDK.init(Context,Appid, Appkey,ChannelId,InitializeCallback); |
121 | 121 | ||
122 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 | 122 | InitializeCallback为初始化回调接口,此接口只有一个回调方法initComplete(int result) result标识是否初始化成功,当result等于GumpSDK.CODE.OK时为成功,其他为失败 |
123 | 123 | ||
124 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 | 124 | #### 2.调用GumpSDK的开始方法,将执行登录流程,需要一个Activity实例作参数 |
125 | 125 | ||
126 | GumpSDK.start(Activity); | 126 | GumpSDK.start(Activity); |
127 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: | 127 | 在此之前,开发者需要注册用户状态监听以接受用户的登录/登出通知,通常如下: |
128 | 128 | ||
129 | GumpSDK.setUserStateListener(new LoginStateListener() { | 129 | GumpSDK.setUserStateListener(new LoginStateListener() { |
130 | @Override | 130 | @Override |
131 | public void onLoginSuccess(GumpUser gumpUser) { | 131 | public void onLoginSuccess(GumpUser gumpUser) { |
132 | //登录成功,用户信息包含在GumpUser对象里 | 132 | //登录成功,用户信息包含在GumpUser对象里 |
133 | } | 133 | } |
134 | 134 | ||
135 | @Override | 135 | @Override |
136 | public void onLoginFailed(int code, String msg) { | 136 | public void onLoginFailed(int code, String msg) { |
137 | //登录出错,根据错误码和信息判断错误类型 | 137 | //登录出错,根据错误码和信息判断错误类型 |
138 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); | 138 | Toast.makeText(MainActivity.this, "Login failed:code="+code+",message="+msg, Toast.LENGTH_SHORT).show(); |
139 | } | 139 | } |
140 | 140 | ||
141 | @Override | 141 | @Override |
142 | public void onLoginCanceled() { | 142 | public void onLoginCanceled() { |
143 | //用户取消登录 | 143 | //用户取消登录 |
144 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); | 144 | Toast.makeText(MainActivity.this, "operate be canceled", Toast.LENGTH_SHORT).show(); |
145 | } | 145 | } |
146 | 146 | ||
147 | @Override | 147 | @Override |
148 | public void onLogout() { | 148 | public void onLogout() { |
149 | //用户登出 | 149 | //用户登出 |
150 | 150 | ||
151 | } | 151 | } |
152 | }); | 152 | }); |
153 | 153 | ||
154 | 如上成功登录后收到的GumpUser对象包含以下信息 | 154 | 如上成功登录后收到的GumpUser对象包含以下信息 |
155 | 155 | ||
156 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! | 156 | gumpUser.getUid();//获取用户的userid,此Id标识唯一用户! |
157 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 | 157 | gumpUser.getAccountType();//用户类型,此类型数据可从GumpPreference常量获取 |
158 | gumpUser.getSessionKey();//登录的sesionKey | 158 | gumpUser.getSessionKey();//登录的sesionKey |
159 | 159 | ||
160 | 160 | ||
161 | #### 3.支付功能 | 161 | #### 3.支付功能 |
162 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 | 162 | 1)使用gump通行证登录,其中除nick外所有参数为必传参数 |
163 | 163 | ||
164 | Bundle payInfo = new Bundle(); | 164 | Bundle payInfo = new Bundle(); |
165 | payInfo.putString("nick", "thi"); | 165 | payInfo.putString("nick", "thi"); |
166 | payInfo.putString("product", "元宝"); | 166 | payInfo.putString("product", "元宝"); |
167 | payInfo.putFloat("amount", 40.0f); | 167 | payInfo.putFloat("amount", 40.0f); |
168 | payInfo.putString("extraInfo", "This is demo!"); | 168 | payInfo.putString("extraInfo", "This is demo!"); |
169 | payInfo.putString("serverId", "B4003"); | 169 | payInfo.putString("serverId", "B4003"); |
170 | payInfo.putString("roleId", "10010"); | 170 | payInfo.putString("roleId", "10010"); |
171 | payInfo.putString("sessionKey","sessionkey"); | 171 | payInfo.putString("sessionKey","sessionkey"); |
172 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); | 172 | GumpSDK.pay(MainActivity.this, payInfo,PurchaseCallback); |
173 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick和roleId外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey | 173 | 调用pay方法时,必须穿入一个bundle对象,包含如上字段,除nick外所有字段必须全部包含,其中sessionKey为登录时返回的sessionKey |
174 | 174 | ||
175 | 175 | ||
176 | 2)IAP支付 | 176 | 2)IAP支付 |
177 | 177 | ||
178 | Bundle payInfo = new Bundle(); | 178 | Bundle payInfo = new Bundle(); |
179 | payInfo.putString("product", "gp_skuId"); | 179 | payInfo.putString("product", "gp_skuId"); |
180 | payInfo.putFloat("amount", 0.1f); | 180 | payInfo.putFloat("amount", 0.1f); |
181 | payInfo.putString("extraInfo", "This is demo!"); | 181 | payInfo.putString("extraInfo", "This is demo!"); |
182 | payInfo.putString("serverId", "100"); | 182 | payInfo.putString("serverId", "100"); |
183 | payInfo.putString("roleId","100123"); | 183 | payInfo.putString("roleId","100123"); |
184 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); | 184 | GumpSDK.iap(MainActivity.this, payInfo, PurchaseCallback); |
185 | 185 | ||
186 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 | 186 | 3)PurchaseCallback为支付状态回调接口,此接口含有3个方法 |
187 | 187 | ||
188 | @Override | 188 | @Override |
189 | public void onPurchaseCompleted(PurchaseResult result) { | 189 | public void onPurchaseCompleted(PurchaseResult result) { |
190 | Log.i(TAG,"purchase completed"); | 190 | Log.i(TAG,"purchase completed"); |
191 | } | 191 | } |
192 | 192 | ||
193 | @Override | 193 | @Override |
194 | public void onPurchaseError(int code, String msg) { | 194 | public void onPurchaseError(int code, String msg) { |
195 | Log.i(TAG,"purchase error"); | 195 | Log.i(TAG,"purchase error"); |
196 | } | 196 | } |
197 | 197 | ||
198 | @Override | 198 | @Override |
199 | public void onPurchaseCanceled() { | 199 | public void onPurchaseCanceled() { |
200 | Log.i(TAG,"purchase canceled"); | 200 | Log.i(TAG,"purchase canceled"); |
201 | } | 201 | } |
202 | 202 | ||
203 | #### 4.注销登录 | 203 | #### 4.注销登录 |
204 | 204 | ||
205 | GumpSDK.logout(Activity); | 205 | GumpSDK.logout(Activity); |
206 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 | 206 | 当此方法调用后,用户退出登录,并会通过LoginStateListener接口通知调用程序!为了便于用户切换登录账户,请在游戏内提供用户注销的触发按钮 |
207 | ## 第二章 常见问题 | 207 | ## 第二章 常见问题 |
208 | ### 问题1: 如何避免混淆对SDK的影响? | 208 | ### 问题1: 如何避免混淆对SDK的影响? |
209 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java | 209 | 解答:有些开发者对接入了SDK的程序进行混淆时,有可能会覆盖某些java |
210 | 类,导致SDK无法正常工作,解决方法如下: | 210 | 类,导致SDK无法正常工作,解决方法如下: |
211 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 | 211 | Ø 请开发者在混淆配置文件proguard.cfg或proguard-project.txt的最后加上 |
212 | 212 | ||
213 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable | 213 | -keepattributes *Annotation*,InnerClasses,SourceFile,LineNumberTable |
214 | -keep public class * extends android.app.Service | 214 | -keep public class * extends android.app.Service |
215 | -keep public class com.google.vending.licensing.ILicensingService | 215 | -keep public class com.google.vending.licensing.ILicensingService |
216 | -keep public class com.android.vending.licensing.ILicensingService | 216 | -keep public class com.android.vending.licensing.ILicensingService |
217 | -keep class com.g.root.view.* {*;} | 217 | -keep class com.g.root.view.* {*;} |
218 | -keep class com.g.root.web.* {*;} | 218 | -keep class com.g.root.web.* {*;} |
219 | -keep class com.g.root.bridge.impl.*{*;} | 219 | -keep class com.g.root.bridge.impl.*{*;} |
220 | 220 | ||
221 | 221 | ||
222 | 使得混淆的时候不会影响SDK的命名空间。 | 222 | 使得混淆的时候不会影响SDK的命名空间。 |