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

£可爱£侵袭症+ 提交于 2019-12-25 01:52:50

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/54231981/isreadytopayrequest-fromjson-cannot-resolve-method-fromjson-java-lang-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!