SpeechRecognizer not available when targeting Android 11
Asked Answered
Z

1

29

While testing an application after increasing the targetLevel to 30, I found that the SpeechRecognizer is not available any more, i.e. SpeechRecognizer.isRecognitionAvailable() always return false.

If I set the targetLevel back to 29, without changing anything else, it is available again. This happens on a real device (Pixel 3a) and the emulator.

It doesn't seem to be a behaviour change. The only requirement mentioned by the Recognizer API is the Manifest.permission.RECORD_AUDIO

I also found no clue in the logcat.

Zoes answered 12/10, 2020 at 13:44 Comment(0)
Z
86

I finally found a solution.

Trying to actually use the (allegedly not available) recognizer lead to this message in the logcat :

10-13 09:19:50.273  1531  1799 I AppsFilter: interaction: PackageSetting{eb6a1b2 my.application.package/10225} -> PackageSetting{ab34503 com.google.android.googlequicksearchbox/10140} BLOCKED
10-13 09:19:50.273  1531  1799 W ActivityManager: Unable to start service Intent { act=android.speech.RecognitionService cmp=com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService } U=0: not found
10-13 09:19:50.273 25348 25348 E SpeechRecognizer: bind to recognition service failed

So the problem seems to be related to this new Android 11 "feature", and the solution was to add a query to the manifest for the blocked intent :

<manifest ...>
    <queries>
        <intent>
            <action android:name="android.speech.RecognitionService" />
        </intent>
    </queries>
Zoes answered 13/10, 2020 at 8:41 Comment(9)
Wow, nice find.Pender
hello, can you check this question #65476514Shawanda
wow, really did not expect this. thank you mah man!Brittaniebrittany
Great find man, exact solution to the problem. +1Confucius
adding intent causes another issue to come up of ":app:processDebugMainManifest". with out adding the intent tag the app runs but Speech Recognition does not workCryotherapy
Seems like there is a new bug on Android 13. I just updated my Android version and now it doesn't work.Scotland
developer.android.com/about/versions/13/…Scotland
They actually removed the Voice Recognition service. "Android 13 removes the SpeechService implementation"Scotland
If I understand correctly, they did not remove the API, they moved the implementation from one app (Google app) to another (Speech Services by Google). This should not be a problem unless the application hard-codes somehow the speech service implementation's provider. Anyway my app still work on Android 13 without any changes in the code using the recognizer, even after increasing the target SDK to API 33Zoes

© 2022 - 2024 — McMap. All rights reserved.