【问题标题】:Play services version issue for SMS Retriever ApiSMS Retriever Api 的播放服务版本问题
【发布时间】:2019-04-03 07:45:20
【问题描述】:

我已经将SMS Retriever Api 及其工作正常集成在具有最新播放服务的设备上(检查播放服务版本 16.xx 及更高版本)
这里的问题是,如果我在带有 Play Services 11.9.xx 的设备上运行它,那么 SMS Retriever 客户端不会被注册,也不会抛出任何错误,它只是跳过并且不起作用! !

但根据docs -

先决条件 - SMS Retriever API 仅在具有 Play 的 Android 设备上可用 服务版本 10.2 及更高版本。


所以它应该可以在我的设备上运行,因为播放服务大于 10.2
请建议我做错了什么!

客户端注册代码:

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")
    }
}



以及使用的依赖:

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

【问题讨论】:

  • 是的,我认为您需要使用较低版本的 google play 服务才能使具有过时 google play 服务库的设备正常工作。尝试将 google play 服务版本降低到 11.9 或更低版本,然后在该设备上重试?话虽如此,通常设备会自动更新到最新的播放服务版本...
  • 奇怪 - In release notes I can see SMS Retriever 是在这个版本中引入的,即 11.0,当我尝试使用 11.4.2 编译和运行应用程序时(因为我的设备有 11.9.x,这是在 11.0 中引入)我认为它会起作用,但它只是为 SmsRetrieverClient 发出 NoClassDefFoundError

标签: android google-play google-play-services google-authentication sms-retriever-api


【解决方案1】:

使用较低版本的播放服务(如下所示)并重试

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

如果您使用的是最新版本的依赖项,请更新设备上的 google play 服务版本。

【讨论】:

    猜你喜欢
    • 2019-08-08
    • 1970-01-01
    • 2019-09-14
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-16
    • 2017-02-13
    相关资源
    最近更新 更多