2016-01-15 13 views
15

Tôi đã triển khai lớp IabHelper trong dự án Android của mình và nó nói rằng 'getBuyIntentToReplaceSkus' không thể được giải quyết. Phương pháp đầy đủ:Lớp IabHelper không hoạt động?

buyIntentBundle = mService.getBuyIntentToReplaceSkus(5, 
mContext.getPackageName(),oldSkus, sku, itemType, extraData); 

tôi thực hiện trong thanh toán ứng dụng trong dự án của tôi nhưng tôi chưa tạo bất kỳ hạng mục cần mua, mặc dù phần còn lại của phương pháp này không có bất kỳ vấn đề.

Trả lời

41

Trợ giúp trong dự án ví dụ của Google khác với tệp aidl có trong SDK 'Thanh toán Google Play' bổ sung. Tôi không biết tại sao họ nghĩ đó là một ý hay. Chỉ cần thay thế aidl trong dự án của bạn với dự án được bao gồm trong dự án ví dụ. Điều này chứa tham chiếu phương thức bị thiếu. Bạn cũng có thể sao chép và dán mã bên dưới vào tệp aidl của mình ở dưới cùng:

/** 
* This API is currently under development. 
*/ 
int stub(int apiVersion, String packageName, String type); 

/** 
* Returns a pending intent to launch the purchase flow for upgrading or downgrading a 
* subscription. The existing owned SKU(s) should be provided along with the new SKU that 
* the user is upgrading or downgrading to. 
* @param apiVersion billing API version that the app is using, must be 5 or later 
* @param packageName package name of the calling app 
* @param oldSkus the SKU(s) that the user is upgrading or downgrading from, 
*  if null or empty this method will behave like {@link #getBuyIntent} 
* @param newSku the SKU that the user is upgrading or downgrading to 
* @param type of the item being purchased, currently must be "subs" 
* @param developerPayload optional argument to be sent back with the purchase information 
* @return Bundle containing the following key-value pairs 
*   "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes 
*       on failures. 
*   "BUY_INTENT" - PendingIntent to start the purchase flow 
* 
* The Pending intent should be launched with startIntentSenderForResult. When purchase flow 
* has completed, the onActivityResult() will give a resultCode of OK or CANCELED. 
* If the purchase is successful, the result data will contain the following key-value pairs 
*   "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response 
*       codes on failures. 
*   "INAPP_PURCHASE_DATA" - String in JSON format similar to 
*         '{"orderId":"12999763169054705758.1371079406387615", 
*         "packageName":"com.example.app", 
*         "productId":"exampleSku", 
*         "purchaseTime":1345678900000, 
*         "purchaseToken" : "122333444455555", 
*         "developerPayload":"example developer payload" }' 
*   "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that 
*         was signed with the private key of the developer 
*         TODO: change this to app-specific keys. 
*/ 
Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName, 
    in List<String> oldSkus, String newSku, String type, String developerPayload); 
+0

Đừng quên xây dựng lại dự án khi bạn đã thay thế/chỉnh sửa tệp. Nếu không xây dựng lại nó, lỗi sẽ không biến mất và bạn có thể nghĩ rằng vấn đề không được giải quyết ... – Barakuda

Các vấn đề liên quan