我正在编码一个包含订阅购买的Android本机应用程序。
我对Google Play开发者API的 Purchases.subscriptions:get 服务有疑问。
这是我的代码:
TokenResponse tokenResponse = new TokenResponse();
tokenResponse.setaccessToken(accESS_TOKEN);
tokenResponse.setRefreshToken(REFRESH_TOKEN);
tokenResponse.setExpiresInSeconds(3600L);
tokenResponse.setScope("https://www.googleapis.com/auth/androidpublisher");
tokenResponse.setTokenType("Bearer");
HttpRequestInitializer credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FactORY)
.setClientSecrets(GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET)
.build()
.setfromTokenResponse(tokenResponse);
AndroidPublisher publisher = new AndroidPublisher.Builder(HTTP_TRANSPORT,JSON_FactORY,credential).
setapplicationName("MyApp").
build();
AndroidPublisher.Purchases purchases = publisher.purchases();
AndroidPublisher.Purchases.Subscriptions.Get get = purchases.subscriptions().get("com.myapp.app.android",mSubscriptionId,mPurchaseToken);
SubscriptionPurchase subscripcion = get.execute();
当我处于调试模式时,这部分代码可以正常运行,并且 Subscriptions.Get 服务会使用与参数 mPurchaseToken 相对应的detail json响应正常。 >
应用程序上以调试模式记录的URL服务示例:
DetailSubs: http : https://www.googleapis.com/androidpublisher/v3/applications/com.myapp.app.android/purchases/subscriptions/sub_1_month/tokens/[mPurchaseToken]
但是,当我使用生成的签名APK测试应用程序时, Subscriptions.Get 服务不起作用,并且我具有以下stacktrace:
System.err: d.e.c.a.b.d.b: 404 Not Found
W System.err: Not Found
I System.out: [CDS]close[45832]
I System.out: close [socket][/0.0.0.0:45832]
W System.err: at d.e.c.a.b.f.d.b.a()
W System.err: at d.e.c.a.b.f.d.b.a()
W System.err: at d.e.c.a.b.f.b$a.a()
[...]
应用程序上的URL服务示例以“签名APK”模式登录:
DetailSubs: http : https://www.googleapis.com/androidpublisher/v3/applications//purchases/subscriptions//tokens/?m=sub_1_month
能否帮助我找到此异常的根源?
感谢您的帮助。
编辑:
此外,我使用此版本的“ Google Play开发者API V3”库:
compile 'com.google.apis:google-api-services-androidpublisher:v3-rev129-1.25.0'