rmbrone / flutter_audio_recorder

Flutter plugin that can support audio recording and level metering
MIT License
121 stars 150 forks source link

Sample rate shouldn't be a mandatory parameter #7

Closed iNima closed 4 years ago

iNima commented 4 years ago

Hi there,

Based on the document the sample rate shouldn't be a mandatory field but in an AndroidX enabled project when I don't set sampleRate I receive this error message:

D/AndroidAudioRecorder(16785): handleHasPermission true
E/MethodChannel#flutter_audio_recorder(16785): Failed to handle method call
E/MethodChannel#flutter_audio_recorder(16785): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
E/MethodChannel#flutter_audio_recorder(16785):  at com.zeno.flutter_audio_recorder.FlutterAudioRecorderPlugin.handleInit(FlutterAudioRecorderPlugin.java:146)
E/MethodChannel#flutter_audio_recorder(16785):  at com.zeno.flutter_audio_recorder.FlutterAudioRecorderPlugin.onMethodCall(FlutterAudioRecorderPlugin.java:105)
E/MethodChannel#flutter_audio_recorder(16785):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#flutter_audio_recorder(16785):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#flutter_audio_recorder(16785):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/MethodChannel#flutter_audio_recorder(16785):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_audio_recorder(16785):  at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#flutter_audio_recorder(16785):  at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#flutter_audio_recorder(16785):  at android.app.ActivityThread.main(ActivityThread.java:6692)
E/MethodChannel#flutter_audio_recorder(16785):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_audio_recorder(16785):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
E/MethodChannel#flutter_audio_recorder(16785):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
E/flutter (16785): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference, null)
E/flutter (16785): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (16785): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (16785): <asynchronous suspension>
E/flutter (16785): #2      FlutterAudioRecorder._init (package:flutter_audio_recorder/flutter_audio_recorder.dart:69:33)
E/flutter (16785): <asynchronous suspension>
E/flutter (16785): #3      new FlutterAudioRecorder (package:flutter_audio_recorder/flutter_audio_recorder.dart:25:21)

I use the plugin version v0.5.2.

nikli2009 commented 4 years ago

Hi buddy, just released 0.5.3, in this build, sampleRate is no longer mandatory param in Android and by default it's 16000(good for voice recognition).

Thanks again for all your help.

iNima commented 4 years ago

No worries @nikli2009 Thanks for your prompt fixes.