mikeg
mikeg

Reputation: 1

IsReadyToPayRequest.fromJson, cannot resolve method 'fromJson java.lang.string'

I am attempting to integrate Android Pay into my application and I am following the tutorial provided b google. However I am stuck at the point where the IsReadyToPayRequest is executed;

IsReadyToPayRequest request =
                IsReadyToPayRequest.fromJson(getIsReadyToPayRequest().toString());
        Task<Boolean> task = mPaymentsClient.isReadyToPay(request);
        task.addOnCompleteListener(
                new OnCompleteListener<Boolean>() {
                    @Override
                    public void onComplete(@NonNull Task<Boolean> task) {
                        try {
                            boolean result = task.getResult(ApiException.class);
                            if (result) {
                                // show Google Pay as a payment option
                            }
                        } catch (ApiException e) {
                        }
                    }
                });

I am getting the error, cannot resolve method 'fromJson java.lang.string'

I am using com.google.android.gms:play-services:12.0.1

Any help would be greatly appreciated.

Upvotes: 0

Views: 378

Answers (1)

maio290
maio290

Reputation: 6742

The fromJson method is relatively new, as you can find here.

According to this, you need a newer library version or use the old Builder if you want to stick to your old version.

Upvotes: 2

Related Questions