voice
voice copied to clipboard
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference [ANDROID]
When I use it on Android the app crashes and I've got this error from logcat
Process: com.******, PID: 18659
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference
at com.wenkesj.voice.VoiceModule.onResults(VoiceModule.java:348)
at android.speech.SpeechRecognizer$InternalListener$1.handleMessage(SpeechRecognizer.java:459)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7664)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)```
It's happening the moment that the speech is finished ! So it shows the results but when it tries to end the speech it crashes with above logs
The VoiceModule.java the mentioned part is this part :
public void onResults(Bundle results) {
WritableArray arr = Arguments.createArray();
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
for (String result : matches) {
arr.pushString(result);
}
...
In my case, this solution works : [@react-native-community/voice or react-native-voice / voice gives exception java.lang.NullPointerException at com.wenkesj.voice.VoiceModule.onResults](https://stackoverflow.com/questions/72213425/react-native-community-voice-or-react-native-voice-voice-gives-exception-java/72213426#72213426)
As far as I checked it's not a solution ...It just removed some parameters from Start function ( which I can't )
In my case, this solution works : [@react-native-community/voice or react-native-voice / voice gives exception java.lang.NullPointerException at com.wenkesj.voice.VoiceModule.onResults](https://stackoverflow.com/questions/72213425/react-native-community-voice-or-react-native-voice-voice-gives-exception-java/72213426#72213426)
@mehdinourollah did you find any solution for this without removing the parameters?
No I couldn't Unfortunately
I managed to fix the crash on android by removing EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS
from the options in Voice.start
I made simple fix and pull request. #435 I need your usage tests and feedback.