jonasoreland / runnerup

A open source run tracker
GNU General Public License v3.0
730 stars 273 forks source link

TTS Installed but not detected #1084

Closed vgiannoul closed 2 years ago

vgiannoul commented 2 years ago

Hello and thanks for your work! It seems that after v2.4.1.0 TTS is not recognized even though it's installed and working on other apps. The audio cues silently fail when tested via the settings. When I downgrade the app, audio cues are working as expected. I'm testing this on a pixel 3a phone running latest grapheneOS (android 12)

gerhardol commented 2 years ago

There are no direct changes to TTS at all, I can only see a few library updates as possibly related (Android 11 targeting in 2.4.2). I have not seen any changed recommendations for Android 12 or that the implementation is not as recommended, so no clues here. Any printouts in the log? (amaybe including "res == ERROR emit()"). Any possibility that you can debug? (add printouts to app/src/main/org/runnerup/view/AudioCueSettingsActivity.java OnInitListener and RUTextToSpeech emitt()).

vgiannoul commented 2 years ago

I was able to install the latest app version and get some logs via adb logcat but I'm not sure what is going on. Still no audio cues and on the same device the older version works as expected. If you could assist me I could provide more info. Thanks again for your time

01-04 15:09:46.764  1143 10085 W InputManager-JNI: Input channel object '39fc8c8 org.runnerup/org.runnerup.view.AudioCueSettingsActivity (client)' was disposed without first being removed with the input manager!
01-04 15:09:48.984 30349 30349 E org.runnerup.workout.feedback.RUTextToSpeech: setLanguage(English) => MISSING: -2
01-04 15:09:48.986 30349 30349 E org.runnerup.workout.feedback.RUTextToSpeech: buffer speak: interval
01-04 15:09:48.987 30349 30349 E org.runnerup.workout.feedback.RUTextToSpeech: buffer speak: 386 meters
01-04 15:09:48.989 30349 30349 E org.runnerup.workout.feedback.RUTextToSpeech: buffer speak: 4 minutes 49 seconds
rickyepoderi commented 2 years ago

Hi! I'm having this same issue but after upgrading my lineage from 17.1 to 18.1 (android 11) and using in both runnerup 2.4.4.0. It seems that since android 11 the app should declare that is going to use the TTS. At least it's commented in this stackoverflow thread and the linked android reference doc. Not tested though. I don't see the android.intent.action.TTS_SERVICE stanza in the AndroidManifest.xml of the app. So we can try this initially.

The final error in the logcat when testing the cue is the following (the tts is null because it cannot be initialized, the onInitdhould pass error although it's not checked):

01-04 18:45:19.417  7194  7194 D AndroidRuntime: Shutting down VM
01-04 18:45:19.417  7194  7194 E AndroidRuntime: FATAL EXCEPTION: main
01-04 18:45:19.417  7194  7194 E AndroidRuntime: Process: org.runnerup.free, PID: 7194
01-04 18:45:19.417  7194  7194 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.speech.tts.TextToSpeech.isLanguageAvailable(java.util.Locale)' on a null object reference
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at org.runnerup.workout.feedback.RUTextToSpeech.<init>(RUTextToSpeech.java:65)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at org.runnerup.view.AudioCueSettingsActivity$2.lambda$$0$org-runnerup-view-AudioCueSettingsActivity$2(AudioCueSettingsActivity.java:341)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at org.runnerup.view.AudioCueSettingsActivity$2$$ExternalSyntheticLambda0.onInit(Unknown Source:2)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.speech.tts.TextToSpeech.dispatchOnInit(TextToSpeech.java:862)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.speech.tts.TextToSpeech.initTts(TextToSpeech.java:840)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:771)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:750)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:734)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at org.runnerup.view.AudioCueSettingsActivity$2.onPreferenceClick(AudioCueSettingsActivity.java:375)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.preference.Preference.performClick(Preference.java:1165)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:260)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.widget.AdapterView.performItemClick(AdapterView.java:330)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.widget.AbsListView.performItemClick(AbsListView.java:1187)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3179)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.widget.AbsListView$3.run(AbsListView.java:4097)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:938)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:223)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7664)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
01-04 18:45:19.417  7194  7194 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
01-04 18:45:19.420  1631  7235 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
01-04 18:45:19.420  1631  2032 W ActivityTaskManager:   Force finishing activity org.runnerup.free/org.runnerup.view.AudioCueSettingsActivity
gerhardol commented 2 years ago

If I add this to the manifest, it still works for me and no warnings and lints so I guess this is fine. Google constantly changes requirements it is hard to keep up and to find what actually need to be done.

tts init is indirectly reported in the callback:

2022-01-04 21:59:31.627 21791-21791/org.runnerup.debug E/org.runnerup.tracker.Tracker$1: state.set(INITIALIZED)

Can someone test this?

rickyepoderi commented 2 years ago

I tested today with my device. The above PR fixes my issue at least. Also testded in the emulator with Android 10 and 11.

vgiannoul commented 2 years ago

Unfortunately I cannot easily build and test this PR (With the latest android studio I tried there was an incompatibility error with the java version). Should the issue be closed and merge since it is already tested by @rickyepoderi? Alternatively I could try again. Thanks again for your feedback

gerhardol commented 2 years ago

Issues are normally closed when the PR is merged If the issue is referred to correctly it is done automatically, now I do it manually