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.

bwt
  • 17,292
  • 1
  • 42
  • 60

1 Answers1

80

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>
bwt
  • 17,292
  • 1
  • 42
  • 60
  • 2
    Wow, nice find. – Gavin Wright Nov 01 '20 at 14:45
  • hello, can you check this question https://stackoverflow.com/questions/65476014/error-insufficient-permissions-with-android-11 – Emma Alden Dec 28 '20 at 11:02
  • 2
    wow, really did not expect this. thank you mah man! – adrianvintu Feb 19 '21 at 09:13
  • Great find man, exact solution to the problem. +1 – ridoy Nov 11 '21 at 06:45
  • 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 work – Cleaton Pais Nov 21 '21 at 12:33
  • 2
    Seems like there is a new bug on Android 13. I just updated my Android version and now it doesn't work. – stavros.3p Aug 28 '22 at 06:53
  • https://developer.android.com/about/versions/13/behavior-changes-all#speech-service – stavros.3p Aug 28 '22 at 06:59
  • They actually removed the Voice Recognition service. "Android 13 removes the SpeechService implementation" – stavros.3p Aug 28 '22 at 06:59
  • 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 33 – bwt Aug 28 '22 at 16:33