问题
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