我们一直在开发以应用购买为中心的应用 我跟着这里的指南;
https://www.codenameone.com/blog/intro-to-in-app-purchase.html
以下列方式实施购买;
public static boolean brought(String sku) {
try{
boolean brought = Purchase.getInAppPurchase().wasPurchased(sku);
return brought;
}catch(Exception e){
}
return false;//error
}
public static void buy(String sku){
Purchase.getInAppPurchase().purchase(sku);
}
使用Google Play正确设置购买,但是当“购买对话框”完成时,应用程序崩溃并显示以下错误/堆栈跟踪(从Google Play控制台获取);
java.lang.RuntimeException:
at android.app.ActivityThread.deliverResults (ActivityThread.java:3736)
at android.app.ActivityThread.handleSendResult (ActivityThread.java:3779)
at android.app.ActivityThread.access$1400 (ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1406)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:5459)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)
Caused by: java.lang.IllegalArgumentException:
at com.codename1.payments.v3.Security.generatePublicKey (Security.java:90)
at com.codename1.payments.v3.Security.verifyPurchase (Security.java:67)
at com.codename1.payments.v3.IabHelper.handleActivityResult (IabHelper.java:480)
at com.codename1.impl.android.CodenameOneActivity.onActivityResult (CodenameOneActivity.java:537)
at android.app.Activity.dispatchActivityResult (Activity.java:6470)
at android.app.ActivityThread.deliverResults (ActivityThread.java:3732)
Caused by: com.codename1.impl.android.util.Base64DecoderException:
at com.codename1.impl.android.util.Base64.decode (Base64.java:546)
at com.codename1.impl.android.util.Base64.decode (Base64.java:474)
at com.codename1.impl.android.util.Base64.decode (Base64.java:420)
at com.codename1.payments.v3.Security.generatePublicKey (Security.java:80)
然后在购买任何电话后
Purchase.getInAppPurchase().wasPurchased(sku)
似乎锁定了应用程序并冻结了UI而没有错误记录到日志中。
我很确定这曾经有用,因为我们过去曾经使用过它。
答案 0 :(得分:1)
确保您已从Google Play控制台将android.licenseKey
构建提示设置为正确的字符串。当我们尝试从Google解析base64值以验证购买时会触发此异常。
如果您只是将其设置为空值或者有一个可能失败的额外字符。