gpt4 book ai didi

c# - 无法使用 Xam.Plugin.Media 插件

转载 作者:太空宇宙 更新时间:2023-11-03 18:54:51 25 4
gpt4 key购买 nike

我有一个使用 Xamarin Forms 构建的 android 应用程序。为了使用手机的摄像头,我安装了 Xam.Plugin.Media 插件并严格按照 this video 的说明进行操作。 .

这是我的代码:

public async void TakePhotoAsAttachment(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();

if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}

var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});

if (file == null)
return;

await DisplayAlert("File Location", file.Path, "OK");

image.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
}

但是,当执行这段代码时:

        var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});

我收到这个错误:

{Java.Lang.ClassNotFoundException: md55b01af31820394fbfb172542d1258596.MediaPickerActivity ---> Java.Lang.ClassNotFoundException: Didn't find class "md55b01af31820394fbfb172542d1258596.MediaPickerActivity" on path: DexPathList[[zip file "/data/app/com.companyname.EClinicForDoctor-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.EClinicForDoctor-1/lib/arm, /data/app/com.companyname.EClinicForDoctor-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <54816278eed9488eb28d3597fecd78f8>:0 at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in :0 at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00017] in :0 at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x0003d] in :0 at Android.Runtime.JNIEnv.FindClass (System.Type type) [0x00084] in :0 at Java.Lang.Class.FromType (System.Type type) [0x00022] in :0
at Android.Content.Intent..ctor (Android.Content.Context packageContext, System.Type type) [0x00000] in :0 at Plugin.Media.MediaImplementation.CreateMediaIntent (System.Int32 id, System.String type, System.String action, Plugin.Media.Abstractions.StoreMediaOptions options, System.Boolean tasked) [0x00000] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaImplementation.cs:411 at Plugin.Media.MediaImplementation.TakeMediaAsync (System.String type, System.String action, Plugin.Media.Abstractions.StoreMediaOptions options) [0x00044] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaImplementation.cs:470 at Plugin.Media.MediaImplementation+d__17.MoveNext () [0x000ab] in C:\projects\mediaplugin\src\Media.Plugin.Android\MediaImplementation.cs:153

--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at EClinicForDoctor.Pages.VisitsPage+d__17.MoveNext () [0x00175] in E:\Doctor Project\Mobile Applications\v1\4\EClinicForDoctor\EClinicForDoctor\EClinicForDoctor\Pages\VisitsPage.xaml.cs:235 --- End of managed Java.Lang.ClassNotFoundException stack trace --- java.lang.ClassNotFoundException: md55b01af31820394fbfb172542d1258596.MediaPickerActivity at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:324) at md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.n_onClick(Native Method) at md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.onClick(ButtonRenderer_ButtonClickListener.java:30) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) 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) Caused by: java.lang.ClassNotFoundException: Didn't find class "md55b01af31820394fbfb172542d1258596.MediaPickerActivity" on path: DexPathList[[zip file "/data/app/com.companyname.EClinicForDoctor-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.EClinicForDoctor-1/lib/arm, /data/app/com.companyname.EClinicForDoctor-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 14 more Suppressed: java.lang.ClassNotFoundException: md55b01af31820394fbfb172542d1258596.MediaPickerActivity at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 15 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available }

然后我从github看了插件的说明它在某种程度上类似于视频的说明,并且发生了相同的错误。如何解决这个问题?

最佳答案

尝试删除项目的bin obj文件夹。

您的编译代码和 NuGet 位于 obj、bin 文件夹中。有时,当您添加任何新的 NuGet 时,它不会进入 obj、bin 文件夹。它只使用早期编译的 NuGet 作为 bin 和 obj 的缓存。删除所有 bin、obj 强制编译器创建新的 bin obj 文件夹并重新编译解决方案。每当您在解决方案中添加任何新的 NuGet 时,最好删除 bin, obj。

关于c# - 无法使用 Xam.Plugin.Media 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48205739/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com