IabHelper返回空库存

时间:2016-05-20 17:44:40

标签: android in-app-purchase in-app-billing

早上好,我正在使用示例“Trivial Drive”中的util类来编程 应用程序内购买我的应用程序。 所以我正在使用iabHelper与谷歌播放进行交流。 当我查询可用项目的清单时,结果是成功的 但是,虽然我已经发布了一个项目,但是返回的库存是空的 在我的开发者控制台中销售  有没有人有同样的问题? 这是代码和日志。

BILLING MANAGER

public BillingManager(Context context, IabHelper.OnIabSetupFinishedListener listener){

    Log.d(TAG, "Costruzione...");

    this.context = context;



    iabHelper = new IabHelper(context, base64Key);
    iabHelper.enableDebugLogging(enableLogging);
    iabHelper.startSetup(listener);
}

public void setupReceiver(Activity activity){

    receiver = new IabBroadcastReceiver(BillingManager.getBilligBroadcastListener());
    IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
    activity.registerReceiver(receiver, broadcastFilter);
}

/**Distrugge questo BillingManager */
public void destroy(Activity activity){

    Log.d(TAG, "Distruzzione del Billing Manager...");

    Log.d(TAG, "Chiudo il broadcast receiver");
    activity.unregisterReceiver(receiver);

    if(iabHelper != null){
        iabHelper.dispose();
    }

    try {
        Log.d(TAG, "Invoco Finalize...");
        finalize();
    }
    catch(java.lang.Throwable e){

    }
}

主要活动

protected void onResume() {
    super.onResume();

    if(!started) {

        started = true;

        //------------------------------------------------------------------------------------------
        //          CODICE PER GLI ACQUISTI IN APP
        //------------------------------------------------------------------------------------------

        billingManager = new BillingManager(getApplicationContext(), this);

    }
    else{
        finish();
    }
}

public void onIabSetupFinished(IabResult result){

    if(billingManager == null){

        Log.e(TAG, "billingManager nullo nella chiamata di onIabSetupFinished");
        return;
    }

    if(billingManager.getIabHelper() == null){

        Log.e(TAG, "IabHelper nullo nella chiamata di onIabSetupFinished");
        return;
    }

    if(result.isSuccess()){

        //Instanzio il broadcast receiver
        billingManager.setupReceiver(this);

        billingManager.setSetupDone(true);

        Log.d(TAG, "Setup dell'IabHelper e del BroadcastReceiver completato con successo.");
        Log.d(TAG, "Richiedo la lista dei prodotti disponibili");

        billingManager.getIabHelper().queryInventoryAsync(this);
    }
    else{
        //TODO: Messaggio di errore nella creazione dell'IabHelper
        Log.d(TAG, "Errore nel setup dell'IabHelper. Risultato dell'operazione: " + result);
    }

    billingManager.setSetupFinished(true);
}

public void onQueryInventoryFinished(IabResult result, Inventory inventory) {

    Log.d(TAG, "Richiesta dei prodotti acquistabili finita risultato: ");

    if (result.isSuccess()) {

        Log.d(TAG, "Successo. Sono stati trovati i seguenti prodotti: ");

        Purchase premiumUpgrade = inventory.getPurchase(billingManager.getPremiumUpgradeSku());

        if (premiumUpgrade != null) {
            String sku = premiumUpgrade.getSku();

            Log.d(TAG, "Rilevato acquisto in app: " + sku);
            alert("E' stato trovato il seguente prodotto in app: " + premiumUpgrade.toString());
        } else {
            Log.d(TAG, "Nessun prodotto rilevato");
            alert("Non è stato trovato nessun prodotto in-app. Result: " + result);
        }
    }
    else{
        Log.e(TAG, "Fallito. Inventario non ricevuto.");
    }
    //MainActivity.setWaitScreen(false);

    Log.d(TAG, "Distruggo il billing manager e procedo all'avvio della lista.");

    billingManager.destroy(this);
    start();
}

LOG(忽略意大利语中的部分)

05-20 19:51:33.328 24746-24746/cf.portaChiavi D/Billing Manager: Costruzione...
05-20 19:51:33.328 24746-24746/cf.portaChiavi D/IabHelper: Starting in-app billing setup.
05-20 19:51:33.358 24746-24746/cf.portaChiavi D/IabHelper: Billing service connected.
05-20 19:51:33.358 24746-24746/cf.portaChiavi D/IabHelper: Checking for in-app billing 3 support.
05-20 19:51:33.358 24746-24746/cf.portaChiavi D/IabHelper: In-app billing version 3 supported for cf.portaChiavi
05-20 19:51:33.368 24746-24746/cf.portaChiavi D/IabHelper: Subscription re-signup AVAILABLE.
05-20 19:51:33.368 24746-24746/cf.portaChiavi D/Main Activity: Setup dell'IabHelper e del BroadcastReceiver completato con successo.
05-20 19:51:33.368 24746-24746/cf.portaChiavi D/Main Activity: Richiedo la lista dei prodotti disponibili
05-20 19:51:33.368 24746-24746/cf.portaChiavi D/IabHelper: Starting async operation: refresh inventory
05-20 19:51:33.368 24746-24746/cf.portaChiavi D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
05-20 19:51:33.368 24746-24746/cf.portaChiavi D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
05-20 19:51:33.368 24746-25561/cf.portaChiavi D/IabHelper: Querying owned items, item type: inapp

05-20 19:51:33.368 24746-25561/cf.portaChiavi D/IabHelper: Calling getPurchases with continuation token: null
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Owned items response: 0
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Continuation token: null
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Querying SKU details.
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: queryPrices: nothing to do because there are no SKUs.
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Querying owned items, item type: subs
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Package name: cf.portaChiavi
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Calling getPurchases with continuation token: null
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Owned items response: 0
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Continuation token: null
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Querying SKU details.
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: queryPrices: nothing to do because there are no SKUs.
05-20 19:51:33.378 24746-25561/cf.portaChiavi D/IabHelper: Ending async operation: refresh inventory
05-20 19:51:33.388 24746-24746/cf.portaChiavi D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! 
05-20 19:51:33.398 24746-24746/cf.portaChiavi D/Main Activity: Richiesta dei prodotti acquistabili finita risultato: 
05-20 19:51:33.398 24746-24746/cf.portaChiavi D/Main Activity: Successo. Sono stati trovati i seguenti prodotti: 
05-20 19:51:33.398 24746-24746/cf.portaChiavi D/Main Activity: Nessun prodotto rilevato

1 个答案:

答案 0 :(得分:-1)

如果您之前尝试购买android.test.purchased项,则可能会损坏库存。尝试清除Google Play应用的缓存。