flutter speech_to_text recognizerNotAvailable

Viewed 1042

I'm writing an mobile app using flutter. This app uses the package "speech_to_text" for speech recognition. When I test on my Huawei handy (Nova 5 pro), I get the following error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(recognizerNotAvailable, Speech recognition not available on this device, , null)

This error occurs when I call the initialize method. I added following lines in "AndroidManifest.xml" direct under root node "manifest":

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<queries>
    <intent>
        <action android:name="android.speech.RecognitionService" />
    </intent>
</queries>

Does this package support Huawei devices? Is it dependant on google-api? Any help and suggestions are very appreciated!

Xinyu

2 Answers

just add these lines below the permissions in your project android manifest

<queries>
    <intent>
        <action android:name="android.speech.RecognitionService" />
    </intent>
</queries>

Just set targetSdkVersion in build.gradle to 28.

Related