android – Dependency for SMS Retriever API-ThrowExceptions

Exception or error:

I am trying to implement SMS Retriever API, but I am unable to find classes like SmsRetrieverClient. I’m not able to import them.

Refer to the following sample code:

 SmsRetrieverClient client = SmsRetriever.getClient(context);
 Task<Void> task = client.startSmsRetriever();
 task.addOnSuccessListener(new OnSuccessListener<Void>() {});

I have added following dependency, after which I am able to refer the classes:

compile ''
  1. But as this include all service API, I want to know the dependency specific to SMS Retriever API

    I have referred to this doc for all dependency and added following, but it did not work.
  2. Also, is it necessary to have 11.x.x versions?

How to solve:

Try adding the following dependency:

implementation "$playServicesVersion"

replace $playServicesVersion with the play services version you are using.


Do you have error logs that may show the problem? For the meantime, try the old version first from the SMS Retriever document:

The SMS Retriever API is available only on Android devices with Play
services version 10.2 and newer.

Check this one if the old version imports SmsRetrieverClient successfully.

Leave a Reply

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