NateRickard / Plugin.AudioRecorder

Audio Recorder plugin for Xamarin and Windows
MIT License
164 stars 68 forks source link

System.NotImplementedException: The method or operation is not implemented #1

Closed yhj200722 closed 6 years ago

yhj200722 commented 7 years ago

System.NotImplementedException: The method or operation is not implemented occured in my xamarin.forms app when "new AudioRecorderService{......} operation"

NateRickard commented 7 years ago

@yhj200722 please ensure you've added the NuGet package to each platform project in addition to the PCL, as stated in the setup instructions.

sushibear commented 7 years ago

@NateRickard does this work ONLY for PCL and not for SHARED projects? I get the same error in my Android/iOS Shared Xamarin Project!?

Just tried using it inside an activity just like in your Sample (https://github.com/NateRickard/Plugin.AudioRecorder/blob/master/Samples/AudioRecord.Android/MainActivity.cs)

recorder = new AudioRecorderService { StopRecordingOnSilence = false, StopRecordingAfterTimeout = true, TotalAudioTimeout = TimeSpan.FromSeconds(30) };

Still throwing NotImplementedException Error :(

NateRickard commented 7 years ago

@sushibear Should work for any iOS/Android/UWP platform project(s) since there are assemblies in the NuGet package specific to those platforms. You have to install the NuGet package in each of the platform projects the shared project is referenced from.

I've added a Xamarin.Forms sample using a shared project, you can find it here: https://github.com/NateRickard/Plugin.AudioRecorder/tree/master/Samples/Forms

Kokujou commented 6 years ago

i really have no clue but... it is not working no matter what i do. and... "NotImplementedException" only occurs when... well the method we are calling simple does not exist. is there maybe something wrong with the NuGet project?

NateRickard commented 6 years ago

@Kokujou shouldn't be anything wrong with the package - the working samples included in this repo use the package. As stated above, this error would typically indicate you haven't included the package in a platform-specific project (Android, iOS, UWP), so it can't find the proper dll to load.

Kokujou commented 6 years ago

@NateRickard but i downloaded it via nuget and included it in all my subprojects! this line is in my packages.config:

i don't know what i could've done wrong. and i do even find the DLL in the path which is shown commented when i go to the definition of AudioRecorderService

the dll is even listed under "references"

and now, just to be sure, i deleted the reference under android which was pointing to "portable45-net45+win8+wpa81" and replaced it to the one lying in monoandroid 71 (btw: i'm using android 7.0 as target framework. it says yours is compatible with api 16+ I don't know if maybe there is something wrong) - still not working.

quinnhoener commented 6 years ago

@NateRickard, I'm also experiencing this same thing. I even uninstalled and re-installed the Nuget package to the Droid project and it's still throwing this issue. I've double checked I have all the correct Android permissions set. I'm using Android packages 25.3.1, the same as your Forms sample. I'm not sure what the issue could be. iOS seems to be working perfectly fine.

quinnhoener commented 6 years ago

@NateRickard not sure if this makes the difference, but I have my Xamarin Forms project setup as PCL. I noticed your sample has the Forms shared project as a Shared code project.

Kokujou commented 6 years ago

@NateRickard i don't wanna nag but it's kind of urgent because my deadline is at the 24th. could you please help?

NateRickard commented 6 years ago

@quinnhoener See here for a PCL-based Forms project that's using this plugin.

@Kokujou can you create a repo that reproduces your issue? I can clone and review the issue that way.

I'd be interested to know the details in (both of) your projects... this lib should work fine with legacy PCL-based projects, provided it uses the proper PCL profile (profile111). As PCL is now deprecated, newer Forms projects are based on .NET Standard 2.0, which may be another story. Need to find time to migrate this whole lib to .NET Standard or find someone who can create a PR.

Kokujou commented 6 years ago

it's not like there has something to be cloned... it happens if you just open a new Xamarin Project and use that line AudioRecorderServer x = new AudioRecorderService(); but i have to say i'm very new to everything which has to do with Xamarin. i just created an empty app as shared project and Xamarin.Forms. then i updated Forms to ... 2.4.0.282, downloaded your nuget package's latest version and wrote that line into my App() constructor. nothing else.

i mean it's not like i'm gonna get exmatriculated if i don't use that audio stuff but it'd be nice to have it, i wanted to use it for speech recognition and maybe text to speech.

NateRickard commented 6 years ago

Still can't reproduce this and many people are using it w/o experiencing this issue, which leads me to believe it's a project config issue or similar. Closing this again for now - if anyone can create a reproduction and put it on GitHub I can try and troubleshoot.

DivyaG014 commented 6 years ago

Hi I am also facing the same issue when I try to access the camera in android phone using Xam.plugin.media. I am using visual studio 2017, Xamarin - 4.11.0.756, Xamarin.Android SDK - 9.0.0.19. here is the full stack trace of the exception i am getting :--

{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotImplementedException: The method or operation is not implemented. at System.Reflection.Assembly.GetName (System.Boolean copiedName) [0x00000] in :0 at System.Reflection.Assembly.GetName () [0x00000] in :0 at Android.Runtime.JNIEnv.GetJniName (System.Type type) [0x00025] in <2ea27230a5464cd294f5acb17cd0ebb4>:0 at Android.Runtime.JNIEnv.FindClass (System.Type type) [0x00009] in <2ea27230a5464cd294f5acb17cd0ebb4>:0 at Java.Lang.Class.FromType (System.Type type) [0x00022] in <2ea27230a5464cd294f5acb17cd0ebb4>:0 at Android.Content.Intent..ctor (Android.Content.Context packageContext, System.Type type) [0x00000] in <2ea27230a5464cd294f5acb17cd0ebb4>:0 at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in :0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00017] in :0 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in :0 at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in :0 at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000ba] in :0 at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in :0 at NInterpret.Interpreter.newobj (System.Collections.Generic.Dictionary2[TKey,TValue] gargs, Mono.Cecil.MethodReference m, System.Object[] createInstanceArgs) [0x00305] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption1[T] lastException) [0x03d5e] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpret (System.Object[] args) [0x00098] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.callAMethod (NInterpret.AMethod m, NInterpret.AType[] ptypes, NInterpret.AType[] genericMethodArgs, System.Collections.Generic.Dictionary2[TKey,TValue] genericArgsIndex, System.Object[] args, System.Collections.Generic.List1[T] byRefArgs, Microsoft.FSharp.Core.FSharpOption1[T] byRefTarget, System.Object target, System.Boolean virtualCall) [0x00183] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.callMethodReference (System.Collections.Generic.Dictionary2[TKey,TValue] gargs, Mono.Cecil.MethodReference ms, System.Boolean virtualCall) [0x00383] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption1[T] lastException) [0x00fba] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpret (System.Object[] args) [0x00098] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.callAMethod (NInterpret.AMethod m, NInterpret.AType[] ptypes, NInterpret.AType[] genericMethodArgs, System.Collections.Generic.Dictionary2[TKey,TValue] genericArgsIndex, System.Object[] args, System.Collections.Generic.List1[T] byRefArgs, Microsoft.FSharp.Core.FSharpOption1[T] byRefTarget, System.Object target, System.Boolean virtualCall) [0x00183] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.callMethodReference (System.Collections.Generic.Dictionary2[TKey,TValue] gargs, Mono.Cecil.MethodReference ms, System.Boolean virtualCall) [0x00383] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption1[T] lastException) [0x00fba] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption1[T] lastException) [0x0013b] in <5b4cad727eef0f2aa745038372ad4c5b>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0 --- End of inner exception stack trace --- at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0004b] in :0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 at NInterpret.Interpreter.callAMethod (NInterpret.AMethod m, NInterpret.AType[] ptypes, NInterpret.AType[] genericMethodArgs, System.Collections.Generic.Dictionary2[TKey,TValue] genericArgsIndex, System.Object[] args, System.Collections.Generic.List1[T] byRefArgs, Microsoft.FSharp.Core.FSharpOption1[T] byRefTarget, System.Object target, System.Boolean virtualCall) [0x0049c] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.callMethodReference (System.Collections.Generic.Dictionary2[TKey,TValue] gargs, Mono.Cecil.MethodReference ms, System.Boolean virtualCall) [0x00383] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption1[T] lastException) [0x00fba] in <5b4cad727eef0f2aa745038372ad4c5b>:0 at NInterpret.Interpreter.interpretBlock (System.Object[] args, System.Object[] locals, Mono.Cecil.Cil.Instruction initialInstruction, Microsoft.FSharp.Collections.FSharpSet1[T] inTries, Microsoft.FSharp.Core.FSharpOption1[T] lastException) [0x0013b] in <5b4cad727eef0f2aa745038372ad4c5b>:0 }

Please let me know if i am missing something here Or suggest me some solution for this

NateRickard commented 6 years ago

@DivyaG014 you should log your issue on that plugin's repo: https://github.com/jamesmontemagno/MediaPlugin