2014-10-29 40 views
4

我正在設置和測試應用內結算。我設法購買了android.test.purchased,它做了它應該做的。但現在我需要消耗它來繼續我的測試。問題是我無法到達庫存。刷新廣告資源時出錯。應用內結算

當這被稱爲我得到result.isFaliure()被調用,我無法獲得庫存。

IabHelper.QueryInventoryFinishedListener _gotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { 

     @Override 
     public void onQueryInventoryFinished(IabResult result, Inventory inventory) { 

      if (_iabHelper == null) return; 

      if (result.isFailure()) { 
       Log.d(TAG, "Failed to query inventory: " + result); 
       return; 
      } 

      Log.d(TAG, "Query inventory was successful."); 

      Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM); 
      _isPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase)); 
      Log.d(TAG, "User is " + (_isPremium ? "PREMIUM" : "NOT PREMIUM")); 

      update(); 
     } 
    }; 

它記錄錯誤消息

無法查詢庫存:IabResult:錯誤刷新庫存 (查詢擁有項目)。 (響應:-1003:購買簽名 驗證失敗)

android.test.purchased仍然擁有 - 它不會讓我再次購買它。我的手機有網絡連接,所以不是這樣。

我還沒有將已簽名的APK上傳到Google Play,即使我使用Google靜態ID進行測試,這是否也很重要?

回答

10

解決了它... 似乎有靜態購買ID的問題。 這裏有一個sollution我THIS線程發現:

If you have used the android.test.purchased then one way to get rid of the error is to do the following:- 

1. Edit Security.java and change the "return false" line in the 
    verifyPurchase to "return true" - this is temporary, we'll be 
    putting it back in a minute. 
2. In your QueryInventoryFinishedListener, after the "if 
    (result.isFailure()) {...}" lines add the following to consume and 
    get rid of your never ending android.test.purchased item:- 

    if (inventory.hasPurchase(SKU_ANDROID_TEST_PURCHASE_GOOD)) { 
    mHelper.consumeAsync(inventory.getPurchase(SKU_ANDROID_TEST_PURCHASE_GOOD),null); 
    } 
3. Run your app so the consunmeAsync happens, this gets rid of the 
    "android.test.purchased" item on the server. 
4. Remove the consumeAsync code (or comment it out). Back in the 
    Security.java, change the "return true" back to "return false". 
2

我找到了答案here

「這裏有一個建議:請確保您的結算鍵(base64EncodedPublicKey)被正確地保存這是我的問題,畢竟那個......」

base64EncodedPublicKey是從另一個aplication ...

這是我的解決方案。

+0

嘿,你!救了我! – 2014-12-23 10:59:43