2

I have already integrated SMS Retriever Api and its working fine on devices with latest play services (checked with play services version 16.x.x and above)

The issue here is if I am running it on a device with Play Services 11.9.xx then the SMS Retriever client doesn't get registered also no error is thrown it simply skips over and doesn't work !!

But As per the docs -

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


So it should have worked with my device as play services was greater than 10.2
Please suggest what I am doing wrong !!

The code used to register client :

fun setRetrieveSmsTaskListener(context: Context) {
    val client = SmsRetriever.getClient(context)
    val task = client.startSmsRetriever()
    task.addOnSuccessListener {
        LogUtils.debugLog(LOG_TAG, "Sms retriever api task Success")
    }

    task.addOnFailureListener {
        LogUtils.debugLog(LOG_TAG, "Failure Sms retriever api task with exception $it")
    }

    task.addOnCanceledListener {
        LogUtils.debugLog(LOG_TAG, "Canceled Sms retriever api task with exception")
    }
}



And the depencies used :

implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
shadygoneinsane
  • 2,226
  • 1
  • 24
  • 47
  • Yes I think you need to use a google play service with lower version in order for devices that have out-dated google play service libraries to work. Try simply decrease the google play service version to 11.9 or lower and try again on that device? With that said, normally devices will auto update to the latest play service version though... – Sira Lam Apr 03 '19 at 09:54
  • Its strange - [In release notes I can see](https://developers.google.com/android/guides/releases#june_2017_-_version_110) that SMS Retriever was introduced in this version i.e 11.0 and when I try to compile and run the app with ver 11.4.2 (since my device has 11.9.x and this was introduced in 11.0) I thought it would work but Its simply giving out a `NoClassDefFoundError` for `SmsRetrieverClient` – shadygoneinsane Apr 03 '19 at 12:00

1 Answers1

1

Use lower version of play service(like below) and try again

implementation 'com.google.android.gms:play-services-auth-api-phone:11.0.4'

Or update the google play service version on device if you are using latest version of dependencies.