androidandroid-11android-speech-api

SpeechRecognizer not available when targeting Android 11


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.


Solution

  • 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>