java android nullpointerexception in-app-billing android-billing

java - IabHelper error de Android(NullPointerException) launchPurchaseFlow?



in-app-billing android-billing (0)

Estoy usando los últimos archivos de la versión de facturación en la aplicación de Google. Hoy recibí un error en mi teléfono cuando descargué la aplicación (traté de repetir los pasos pero el error ya no aparece).

Digamos que en mi MainActivity tengo un botón que le ofrece al usuario comprar un producto integrado en la aplicación. Mi actividad llama a este constructor:

public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener) { launchPurchaseFlow(act, sku, requestCode, listener, ""); }

De este modo:

mHelper.launchPurchaseFlow(MainActivity.this, SKU_UNLOCKED, RC_REQUEST, mPurchaseFinishedListener, "");

Y hoy recibí este error NullPointerException:

java.lang.NullPointerException at xxx.xxx.xxxxx.util.IabHelper.launchPurchaseFlow(IabHelper:386) at xxx.xxx.xxxxx.util.IabHelper.launchPurchaseFlow(IabHelper:338) at xxx.xxx.xxxxx.MainActivity$6.onClick(MainActivity:422)

La línea 422 de MainActivity es mHelper.launch ... La línea 338 de IabHelper es el constructor.

Luego dentro de launchePurchaseFlow:

Línea 386:

Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData);

Que está dentro de este bloque try-catch:

try { logDebug("Constructing buy intent for " + sku + ", item type: " + itemType); Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData); int response = getResponseCodeFromBundle(buyIntentBundle); if (response != BILLING_RESPONSE_RESULT_OK) { logError("Unable to buy item, Error response: " + getResponseDesc(response)); flagEndAsync(); result = new IabResult(response, "Unable to buy item"); if (listener != null) listener.onIabPurchaseFinished(result, null); return; } PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT); logDebug("Launching buy intent for " + sku + ". Request code: " + requestCode); mRequestCode = requestCode; mPurchaseListener = listener; mPurchasingItemType = itemType; act.startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } catch (SendIntentException e) { logError("SendIntentException while launching purchase flow for sku " + sku); e.printStackTrace(); flagEndAsync(); result = new IabResult(IABHELPER_SEND_INTENT_FAILED, "Failed to send intent."); if (listener != null) listener.onIabPurchaseFinished(result, null); } catch (RemoteException e) { logError("RemoteException while launching purchase flow for sku " + sku); e.printStackTrace(); flagEndAsync(); result = new IabResult(IABHELPER_REMOTE_EXCEPTION, "Remote exception while starting purchase flow"); if (listener != null) listener.onIabPurchaseFinished(result, null); }

¿Alguna idea de por qué? ¿Puede ser la "actividad principal" esto? Gracias de antemano.