Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid TextToSpeech app null pointer exception
    primarykey
    data
    text
    <p>I am getting a null pointer exception report in the android developer console. I need some advise as to what possibly is the problem here, the stack trace is like this</p> <pre><code>java.lang.NullPointerException at com.myfreeapp.workers.Speaker.onInit(Speaker.java:57) at android.speech.tts.TextToSpeech$1.onServiceConnected(TextToSpeech.java:451) at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1247) at android.app.ActivityThread$PackageInfo$ServiceDispatcher$RunConnection.run(ActivityThread.java:1264) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4668) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>The relevant code snippet in my app is </p> <pre><code>public Speaker(final Context context, final Settings settings) { this.settings = settings; params = new HashMap&lt;String, String&gt;(); params.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM)); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "myfreeapps"); tts= new TextToSpeech(context, this); Utils.log(TAG, "Created TextToSpeech.."); } @Override public void onInit(final int status) { Utils.log(TAG, "TTS onInit.."); //below is line 57 mentioned in the stack trace tts.setOnUtteranceCompletedListener(new SpeechFinishedListener()); tts.setLanguage(Locale.getDefault()); tts.setSpeechRate(settings.getSpeed()); tts.setPitch(settings.getPitch()); ready = true; } </code></pre> <p>Please first of all I need to be clear what exactly is null.. Is the stack trace pointing to variable tts on line 57 to be null..?</p> <p>Or is the null pointer exception happening inside the TextToSpeech method setOnUtteranceCompletedListener ?</p> <p>The Speaker instance is created on the main thread in a sticky service, and when I debug my code the callback from TextToSpeech also comes back on the same thread..</p> <p>I don't understand how could the variable tts be null ??? </p> <p>By the way this problem is not reproducible on my end. I have this stack strace reported several times on the developer console.</p> <p>Please advise, </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload