CreateWalletObjectsRequest is missing from com.google.android.gms.wallet API-ThrowExceptions

Exception or error:

As per the given link: https://developers.google.com/wallet/objects/savetowalletnative

I am trying to run the sample application, but in this below method, I am not able to find CreateWalletObjectsRequest. It says:

“CreateWalletObjectsRequest cannot be resolved to a type”

public void saveToWallet(View view){

    LoyaltyWalletObject wob = generateObject();


    CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
    Wallet.createWalletObjects(googleApiClient, request, SAVE_TO_WALLET);

}
How to solve:

Google hasn’t opened Save to Wallet api for everyone yet. We had to get a special Google Play Services AAR directly from Google, along with a lot of help from a Googler to get it functioning (the sample is out of date).

###

As of now, you’ll need to work with your Google contact to get the second-party library to integrate Android Pay. Once you get the aar file, you can import it into your project and add it as a dependency.

Now, the ‘createWalletObjects’ method call in your question has shifted in its location and signature; its now as follows:

Wallet.WalletObjects.createWalletObjects(googleApiClient, request, SAVE_TO_WALLET);

The SAVE_TO_WALLET is the integer request code that you’ll identify the request in your onActivityResult(). Creating the request as such is described in the “Create an object” section of https://developers.google.com/save-to-android-pay/guides/android/add-button-to-your-app

Leave a Reply

Your email address will not be published. Required fields are marked *