我有一个应用程序,在其中添加了应用内计费(v3)。我测试的设备数量虽然很少,但已发布的应用似乎运行良好。该代码已使用proguard进行混淆,但我保留了相应的proguard mapping.txt。
有几个购买成功了,但我也收到了崩溃报告。然后我使用retrace.bat来翻译崩溃堆栈跟踪,并得到了以下结果:
java.lang.NullPointerException
at com.mycompany.mygame.util.IabHelper.void startSetup(com.mycompany.mygame.util.IabHelper$OnIabSetupFinishedListener)(Unknown Source)
void dispose()
void launchPurchaseFlow(android.app.Activity,java.lang.String,int,com.mycompany.mygame.util.IabHelper$OnIabPurchaseFinishedListener,java.lang.String)
boolean handleActivityResult(int,int,android.content.Intent)
com.mycompany.mygame.util.Inventory queryInventory$337baa91(boolean,java.util.List)
void queryInventoryAsync$69bb631c(java.util.List,com.mycompany.mygame.util.IabHelper$QueryInventoryFinishedListener)
java.lang.String getResponseDesc(int)
int getResponseCodeFromBundle(android.os.Bundle)
int queryPurchases(com.mycompany.mygame.util.Inventory,java.lang.String)
int querySkuDetails(java.lang.String,com.mycompany.mygame.util.Inventory,java.util.List)
void logDebug(java.lang.String)
at com.mycompany.mygame.util.IabHelper.void startSetup(com.mycompany.mygame.util.IabHelper$OnIabSetupFinishedListener)(Unknown Source)
void dispose()
void launchPurchaseFlow(android.app.Activity,java.lang.String,int,com.mycompany.mygame.util.IabHelper$OnIabPurchaseFinishedListener,java.lang.String)
boolean handleActivityResult(int,int,android.content.Intent)
com.mycompany.mygame.util.Inventory queryInventory$337baa91(boolean,java.util.List)
void queryInventoryAsync$69bb631c(java.util.List,com.mycompany.mygame.util.IabHelper$QueryInventoryFinishedListener)
java.lang.String getResponseDesc(int)
int getResponseCodeFromBundle(android.os.Bundle)
int queryPurchases(com.mycompany.mygame.util.Inventory,java.lang.String)
int querySkuDetails(java.lang.String,com.mycompany.mygame.util.Inventory,java.util.List)
void logDebug(java.lang.String)
at com.mycompany.mygame.util.IabHelper$2.void run()(Unknown Source)
at java.lang.Thread.run(Thread.java:1019)
我对如何阅读堆栈跟踪有点模糊,但我猜测可能在OnIabPurchaseFinishedListener中存在空指针引用?如果是这样,那么可能是怎么发生的呢?
编辑:堆栈跟踪中出现“launchPurchaseFlow”这个事实是否意味着程序在用户尝试购买某些东西时崩溃了?
编辑:按要求这里是监听器:
/**
* Callback that notifies when a purchase is finished.
*/
public interface OnIabPurchaseFinishedListener {
/**
* Called to notify that an in-app purchase finished. If the purchase was successful,
* then the sku parameter specifies which item was purchased. If the purchase failed,
* the sku and extraData parameters may or may not be null, depending on how far the purchase
* process went.
*
* @param result The result of the purchase.
* @param info The purchase information (null if purchase failed)
*/
public void onIabPurchaseFinished(IabResult result, Purchase info);
}
OnIabSetupFinishedListener
监听器代码。 - ρяσѕρєя K