react-native-sound-recorder icon indicating copy to clipboard operation
react-native-sound-recorder copied to clipboard

Sometimes Android crash on stop

Open kayzenkayzen opened this issue 5 years ago • 3 comments

Sometimes crash when stop recording with this error:

Fatal Exception: java.lang.NumberFormatException Invalid int: "null" com.kevinresol.react_native_sound_recorder.RNSoundRecorderModule.stop


For some reason, we are receiving null as duration, so parseInt expect an integer but receive null then crashes

int duration = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));

kayzenkayzen avatar Apr 14 '20 20:04 kayzenkayzen

That's weird, does the audio file actually exist?

kevinresol avatar Apr 15 '20 01:04 kevinresol

I suppose yes, since it only happens in some cases, anyway, I think that maybe it may have failed in start and I am also calling the stop in some case

Do you think that may be the problem? Are you sure that if the start was correct, the stop should never return that error?

kayzenkayzen avatar Apr 15 '20 19:04 kayzenkayzen

Sorry for the late reply, but I recommend inserting some code on java side to ensure the file exists before grabbing its duration.

kevinresol avatar Aug 19 '20 15:08 kevinresol