sinisha
sinisha

Reputation: 1013

Text-to-speech output screen crashing

I am working on a custom text-to-speech engine for android (just for one language). On most phones everything works correctly, but I have problems on nexus 4 with Kit Kat installed. My engine is successfully installed and it is visible under the available engines. I can choose it as my preferred engine. After I click on language options for my engine an alert dialog with just one language available appears(it's normal). But after I click on it, settings app crashes. It also happens every time after that when I try to open Settings/Language&Input/Text-to-speech output. I can see that under the Default language option Checking... is written. When I check Stack trace I can see that MissingResourceExceptions: No 3-letter language code for locale is thrown in function com.android.setting.tts.TextToSpeechSettings.CheckDefaultLocale()

I discovered that I really made a mistake with my language ISO3 code and I fixed it. When I install this version to Nexus 4 phone, which had no previous version of my app installed, crashes don't happen anymore. But when it is installed on the phone, which had previous version, the problem exists (although old version was uninstalled). I can see that Settings app is still using the old (wrong) ISO3 code. How is it possible if that first version was successfully uninstalled?

I must say that I can use the talkback optins with my engine. But because of crashes it is impossible to change the preferred engine once my engine was chosen

Here is my stacktrace

 03-10 11:11:35.934: E/AndroidRuntime(10608): FATAL EXCEPTION: main
03-10 11:11:35.934: E/AndroidRuntime(10608): Process: com.android.settings, PID: 10608
03-10 11:11:35.934: E/AndroidRuntime(10608): java.util.MissingResourceException: No 3-letter language code for locale: hebrew
03-10 11:11:35.934: E/AndroidRuntime(10608):    at java.util.Locale.getISO3Language(Locale.java:540)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at com.android.settings.tts.TextToSpeechSettings.evaluateDefaultLocale(TextToSpeechSettings.java:284)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at com.android.settings.tts.TextToSpeechSettings.checkDefaultLocale(TextToSpeechSettings.java:270)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at com.android.settings.tts.TextToSpeechSettings.onInitEngine(TextToSpeechSettings.java:251)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at com.android.settings.tts.TextToSpeechSettings$1.onInit(TextToSpeechSettings.java:128)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.speech.tts.TextToSpeech.dispatchOnInit(TextToSpeech.java:701)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.speech.tts.TextToSpeech.access$1400(TextToSpeech.java:58)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute(TextToSpeech.java:1509)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute(TextToSpeech.java:1471)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.os.AsyncTask.finish(AsyncTask.java:632)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.os.Handler.dispatchMessage(Handler.java:102)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.os.Looper.loop(Looper.java:136)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at android.app.ActivityThread.main(ActivityThread.java:5017)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at java.lang.reflect.Method.invokeNative(Native Method)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at java.lang.reflect.Method.invoke(Method.java:515)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-10 11:11:35.934: E/AndroidRuntime(10608):    at dalvik.system.NativeStart.main(Native Method)
03-10 11:11:35.944: W/ActivityManager(598):   Force finishing activity com.android.settings/.SubSettings
03-10 11:11:35.944: W/ActivityManager(598):   Force finishing activity com.android.settings/.SubSettings
03-10 11:11:36.445: W/ActivityManager(598): Activity pause timeout for ActivityRecord{432ad308 u0 com.android.settings/.SubSettings t218 f}

Upvotes: 0

Views: 1802

Answers (1)

brandall
brandall

Reputation: 6144

This in an Android bug and it's very frustrating.

There is a bug reported here (which is fixed as of this, but not yet rolled out to actual devices) and a related one here.

If the locale you are declaring cannot be matched by the system, then the Settings will persist to crash. I tried clearing everything to prevent this from happening, but the System is caching this value somewhere and attempting to match it prior to checking any updated locale in your app.

I changed my code to a locale that I knew would be matched, wiped my device and resintalled...

You need to make sure that you declare the locale correctly as heb-HEB I think!!! But beware!!! If Android doesn't recognise it, you'll get the crash again....

It's best to declare an extra locale that you default to and then check in the Settings if the locale code you are using is displayed correctly. If it's not, don't select it! And try again....

I posted on the bug report above, asking where Android persisted this incorrect locale, but I got no answer.... If you can find out, you wouldn't need to wipe your device. I tried wiping all caches in recovery, but it didn't work.

Upvotes: 2

Related Questions