flutter_tts icon indicating copy to clipboard operation
flutter_tts copied to clipboard

getLanguages method return empty array

Open davidgalarza opened this issue 5 years ago • 3 comments

🐛 Bug Report

Hi I was seeing this error for a long time on my sentry logs, when I reported it a time ago it was marked as related to another issue where was specified that issue happened when there aren't any tts engine installed on the device, but I was able to reproduce it my device and it had installed tts engine.

Reproduction steps

Here is my code

@override
void initState() {
    flutterTts.getLanguages.then((l) {
          this.langCodeSpeech = l.firstWhere((code) {
            return code.toString().startsWith(widget.courseLangCode);
          });
    });
}

This code is located on the init state of an screen I was trying my app on my personal phone opening the screen doing some actions and opening it again, it was working like a charm, but after some time it start to fail with the following exception.

D/TTS     (11483): getLanguages: Attempt to invoke interface method 'java.util.Iterator java.util.Set.iterator()' on a null object reference

I don't know If it is related to the time that I was using the app or it simple randomly happens, but when I restart my app it start to work again.

Device: Huawei P20 lite

Configuration

Version: 1.2.6

Platform:

  • [ ] :iphone: iOS
  • [ x] :robot: Android

davidgalarza avatar Jul 15 '20 18:07 davidgalarza

Any update? I had a lot of reports about that from my app users

davidgalarza avatar Sep 02 '20 16:09 davidgalarza

@davidgalarza is it only with the Huawei P20 lite device? There seems to be other reported issues related to Huawei devices. Do you have any additional logs?

dlutton avatar Sep 03 '20 19:09 dlutton

My device is Huawei 20 lite and I can confirm that it happened to me sometime, is not really common but it happens. The plugin is working great but sometimes I don't know why on my phone if start to fail.

The log when the plugin start to fail:

W/TextToSpeech(22296): getAvailableLanguages failed: not bound to TTS engine
D/TTS     (22296): getLanguages: Attempt to invoke interface method 'java.util.Iterator java.util.Set.iterator()' on a null object reference.
LANGS: [] // print of the returned Languages

When the plugin is working correctly the available languages on my phone are

LANGS: [ko-KR, mr-IN, ru-RU, zh-TW, hu-HU, th-TH, ur-PK, nb-NO, da-DK, tr-TR, et-EE, bs, sw, pt-PT, vi-VN, en-US, sv-SE, ar, su-ID, bn-BD, gu-IN, kn-IN, el-GR, hi-IN, fi-FI, km-KH, bn-IN, fr-FR, uk-UA, en-AU, nl-NL, fr-CA, sr, pt-BR, ml-IN, si-LK, de-DE, ku, cs-CZ, pl-PL, sk-SK, fil-PH, it-IT, ne-NP, hr, en-NG, zh-CN, es-ES, cy, ta-IN, ja-JP, sq, yue-HK, en-IN, es-US, jv-ID, la, id-ID, te-IN, ro-RO, ca, en-GB]

When I restart my app it start to works again.

Here are some statistic of this error reported by Sentry

Brand Captura de Pantalla 2020-09-03 a la(s) 23 57 02

Android version Captura de Pantalla 2020-09-04 a la(s) 00 01 27

Device models Captura de Pantalla 2020-09-04 a la(s) 00 05 57

Sorry I don't have more logs by now.

davidgalarza avatar Sep 04 '20 06:09 davidgalarza