Reputation: 1918
I have implemented Billing Library from the following url https://developer.android.com/google/play/billing/billing_library_overview#java
I am getting error on this line
if (billingResult.getResponseCode() == BillingResponse.OK) {
it says Cannot resolve symbol 'BillingResponse'
here is the complete code from above link
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingResponse.OK) {
// The BillingClient is ready. You can query purchases here.
}
}
@Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
I have added following dependency in my apps build.gradle
file
dependencies {
...
implementation 'com.android.billingclient:billing:2.1.0'
}
but I am getting error
I cannot even import it manually
import com.android.billingclient.api.BillingClient.BillingResponse;
I know its simple solution is to just replace
BillingResponse.OK
with
BillingClient.BillingResponseCode.OK
but my question is why its not given in documentation then?
Upvotes: 3
Views: 2237
Reputation: 18538
I checked the source codes and figured out the correct code.
Though the code on google documentation says billingResult.getResponseCode() == BillingResponse.OK
it should be billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK
So all you need to do is replace BillingResponse.OK
with BillingClient.BillingResponseCode.OK
Upvotes: 6