I am trying to use the billing library and I am getting info from the official Android Developer site here. But I am finding a lot of trouble. Mainly compiling problems. It looks like that documentation is not completed. When I started following step by step I had to search for a lot of extra information. Now I am stuck trying to do querySkuDetailsAsync() This is my code:
billingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
// The BillingClient is ready. You can query purchases here.
List<String> skuList = new ArrayList<> ();
skuList.add("sp_hide_ads_year_01");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
//*** I want to Continue here ***
}
});
}
}
@Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
The compiler (Android Studio) says:
'onSkuDetailsResponse(BillingResult, List)' in 'Anonymous class derived from com.android.billingclient.api.SkuDetailsResponseListener' clashes with 'onSkuDetailsResponse(BillingResult, List)' in 'com.android.billingclient.api.SkuDetailsResponseListener'; both methods have erasure, yet neither overrides the other
I have no idea what this means. any help here?
By the way, I use
implementation 'com.android.billingclient:billing:2.1.0'
I changed the line:
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList)
for this one, and everything compiled:
public void onSkuDetailsResponse(BillingResult billingResult, List<com.android.billingclient.api.SkuDetails> skuDetailsList)