Closed sudhanshu6247 closed 7 years ago
Are you testing on a device? Which version of Android are you using?
Which versions of React-Native and such are you using?
I'm severely limited to which devices I can test with.
Same here. Testing on Samsung Note5, if no speech recognized I can try again but if it captures something, app crashes right after with the exception below.
(also crashes when there is a backdrop touch)
Shutting down VM
FATAL EXCEPTION: main
Process: com.voicerecognition, PID: 9872
java.lang.AbstractMethodError: abstract method "void com.facebook.react.bridge.ActivityEventListener.onActivityResult(android.app.Activity, int, int, android.content.Intent)"
at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:260)
at com.facebook.react.XReactInstanceManagerImpl.onActivityResult(XReactInstanceManagerImpl.java:627)
at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:135)
at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:77)
at android.app.Activity.dispatchActivityResult(Activity.java:7137)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4921)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4968)
at android.app.ActivityThread.access$1600(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1849)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I'll investigate as soon as I can. It may need some updates because of React Native versions.
I was testing it on android device. In my case problem was due to 'ToastAndroid', when I removed 'ToastAndroid', it started working fine.
Ok @sudhanshu6247 that's actually helpful to know.
@JoaoCnh , Hey, is there any updates for this?
@sudhanshu6247 is this working for you now? I'm facing the same issue. Which "ToastAndroid" are you talking about exactly?
Perhaps should be raised as a separate issue. The original issue seem to be a JS error in the user's code.
I've created a PR for the onActivityResult issue (which is due to a react native change)
@kunal95 yup, this is working for me. Original code was:
async _buttonClick(){
try{
//More Locales will be available upon release.
var spokenText = await SpeechAndroid.startSpeech("Speak yo", SpeechAndroid.GERMAN);
ToastAndroid.show(spokenText , ToastAndroid.LONG);
}catch(error){
switch(error){
case SpeechAndroid.E_VOICE_CANCELLED:
ToastAndroid.show("Voice Recognizer cancelled" , ToastAndroid.LONG);
break;
case SpeechAndroid.E_NO_MATCH:
ToastAndroid.show("No match for what you said" , ToastAndroid.LONG);
break;
case SpeechAndroid.E_SERVER_ERROR:
ToastAndroid.show("Google Server Error" , ToastAndroid.LONG);
break;
/*And more errors that will be documented on Docs upon release*/
}
}
}
I just removed ToastAndroid from each line.
My code is
async _buttonClick(){
try{
//More Locales will be available upon release.
var text = await SpeechAndroid.startSpeech("Speak your message", SpeechAndroid.ENGLISH);
this.props.sendMessage(text);
console.log("spokenText", spokenText);
}catch(error){
console.log("spokenText", error);
switch(error){
case SpeechAndroid.E_VOICE_CANCELLED:
break;
case SpeechAndroid.E_NO_MATCH:
break;
case SpeechAndroid.E_SERVER_ERROR:
break;
/*And more errors that will be documented on Docs upon release*/
}
}
}
@sudhanshu6247 Thats's weird. I'm using RN 0.40.0 and I had to do bunch of changes in onActivityResult
and add BaseActivityEventListener
object to the module.
I've just published v0.5.0. Please check if issues still persist for any of you and please feel free to report new ones.
Many thanks to everyone who contributed for v0.5.0 with PRs
@kunal95 @sudhanshu6247 @de-code @azraelti Anyone try v0.5.0? Can this issue be closed?
@kunal95 @sudhanshu6247 @de-code @azraelti v0.5.1 has been published. If it works well I'll close this issue. Feel free to re-open
whenever I tap on microphone and call the _buttonClick() function, it records voice for 2 seconds and then app gets crashed, giving error "unfortunately app has stopped working" please help.