-
Creator 版本:3.8.6
-
目标平台:Android
-
重现方式:确认billing 连接成功,用queryProductDetailsAsync请求产品详情也有,但是在调用 launchBillingFlow整个游戏崩了或者界面错乱,想在js这一端捕获错误直接弹窗,但是没有任何错误弹窗。
**-
去购买商品
-
@param productId
*/
public async goBuy(proCfgId: number) {
try { let cfg = ConTab.getKey(ConfigType.google_pay, proCfgId); if (!cfg) { tips.alert("配置有误...请检查配置!"); return; } let productId = cfg.product.toString(); if (this.isBillingError) { tips.alert("google_pay_check", () => { }); return; } let productDetail = this._productDetailMap.get(productId); if (!productDetail) { let products = await this.queryProductDetail(); productDetail = this._productDetailMap.get(productId); if (!productDetail) { let tipTxt: string = products && products.length > 0 ? `products:${products[0].getName()}:${products[0].getProductId()}` : ""; tips.alert("购买商品id有误" + productId + tipTxt); return; } } if (this._bClient) { oops.gui.toast("商品已初始化成功"); ViewMgr.instance.openAwait("", 2); } this._lauchPurchaseFlow(productDetail); } catch (err) { tips.alert("goBuy" + (err instanceof Error ? err.message : String(err))); }}
/**- 发起购买
*/
private _lauchPurchaseFlow(productDetails: google.billing.ProductDetails): void {
if (!this._bClient) { oops.gui.toast("google_pay_net"); if (!this.isIniting) { this.initBillingClient(); } return; } try { const params = google.billing.BillingFlowParams.newBuilder().setProductDetailsParamsList( [google.billing.BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(productDetails).build()] ).build(); this._bClient.launchBillingFlow(params); } catch (err) { tips.alert("_lauchPurchaseFlow" + (err instanceof Error ? err.message : String(err))); }}
-
看看as的log,有错误信息么?
这么多游戏
肯定有接成功的
你要是问我
我也不懂啊
稀里糊涂就接完了sdk
我用3.83、3.87
2025-06-25 11:33:59.050 29145-29199 JniHelper fun…g.match.puzzle.challenge.free E Classloader failed to find class of com/cocos/lib/CocosHelper
2025-06-25 11:33:59.050 29145-29199 System.err fun…g.match.puzzle.challenge.free W java.lang.NullPointerException: offerToken is required for constructing ProductDetailsParams for subscriptions.
2025-06-25 11:33:59.050 29145-29199 System.err fun…g.match.puzzle.challenge.free W at com.google.android.gms.internal.play_billing.zzam.zzc(Unknown Source:7)
2025-06-25 11:33:59.050 29145-29199 System.err fun…g.match.puzzle.challenge.free W at com.android.billingclient.api.BillingFlowParams$ProductDetailsParams$Builder.build(Unknown Source:19)
2025-06-25 11:33:59.050 29145-29199 JniHelper fun…g.match.puzzle.challenge.free E Failed to find class com/cocos/lib/CocosHelper
2025-06-25 11:33:59.050 29145-29199 JniHelper fun…g.match.puzzle.challenge.free E Failed to find static java method. Class name: com/cocos/lib/CocosHelper, method name: flushTasksOnGameThreadAtForeground, signature: ()V
报这个错误
可以了,谢谢。
一直再查这个Classloader failed to find class of com/cocos/lib/CocosHelper报错,把下面的内容忽略了。

