尝试调用虚方法'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData

从我的Android应用程序拍照时获取异常 . 我使用了Media Plugin https://github.com/jamesmontemagno/MediaPlugin

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

{Java.Lang.NullPointerException:尝试在空对象上调用虚拟方法'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager,java.lang.String)' Java.Interop.JniEnvironment StaticMethods.CallStaticObjectMethod(Java.Interop.JniObjectReference类型,Java.Interop.JniMethodInfo方法,Java.Interop . )中的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0中的引用 . JniArgumentValue * args)[0x00069] in:0:Android.Runtime.JNIEnv.CallStaticObjectMethod(System.IntPtr jclass,System.IntPtr jmethod,Android.Runtime.JValue * parms)[0x0000e] in:0,Android.Support.V4 . Content.FileProvider.GetUriForFile(Android.Content.Context上下文,System.String权限,Java.IO.File文件)[0x00078]在<3e239b9681084d42bb949c1e01ef500e>中:0在Plugin.Media.MediaPickerActivity.OnCreate(Android.OS.Bundle savedInstanceState) [0x0023f]在C:\ projects \ mediaplugin \ src \中Media.Plugin.Android \ MediaPickerActivity.cs:162 ---抛出异常的前一个位置的堆栈跟踪结束---在<3fd174ff54b146228c505f23cf75ce71>中的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c]:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task)[0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task)[0x00028 ]在<3fd174ff54b146228c505f23cf75ce71>:0中的System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008]在<3fd174ff54b146228c505f23cf75ce71>:0中的System.Runtime.CompilerServices.TaskAwaiter1 [TResult] . 在<3fd174ff54b146228c505f23cf75ce71>中的GetResult()[0x00000]:0在Plugin.Media.MediaImplementation d _16.MoveNext()[0x000c7]中的C:\ projects \ mediaplugin \ src \ Media.Plugin.Android \ MediaImplementation.cs:119 ---堆栈跟踪结束抛出异常的先前位置---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)的<3fd174ff54b146228c505f23cf75ce71>中的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c]:0 [0xf3e]在<3fd174ff54b146228c505f23cf75ce71>:0中的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028]在<3fd174ff54b146228c505f23cf75ce71>:0中的System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(系统.Threading.Tasks.Task任务)[0x00008]在<3fd174ff54b146228c505f23cf75ce71>:0中的System.Runtime.CompilerServices.TaskAwaiter1 [TResult] .GetResult()[0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0 at Propznet.Mobile.Features . Inventory.Helpers.UnitCreateUpdateViewModelBase <b__32_0> d.MoveNext()[0x00091]在E:\ Propznet Mobile \ Source \ Propznet.Mobile \ Propznet.Mobile.Features.Inventory \ Helpers \ UnitCreateUpdateViewModelBase.cs:322 --- End of托管Java.Lang.NullPointerException堆栈跟踪--- java.lang.NullPointerException:尝试调用虚拟方法'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager,java . lang.String)'在android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:583)的空对象引用,android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:557)在android上.support.v4.content.FileProvider.getUriForFile(FileProvider.java:399)at md5f1b52d9f1d5d1981437e7e130649468a.MediaPickerActivity.n_onCreate(Native Method)at md5f1b52d9f1d5d1981437e7e130649468a.MediaPickerActivity.onCreate(MediaPickerActivity.java:42)at android.app.Activity.performCreate(Activity .java:6259)在Android.app.ActivityThread.perleLaunchActivity(ActivityThread.java:2382)的android.app.Anstrumentation.callActivityOnCreate(Instrumentation.java:1130)android.app.ActivityThread.handleLaunchActivity(ActivityThread.jav) a:2493)在Android.app.Handler.dispatchMessage(Handler.java:102)的android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1357)的android.app.ActivityThread.-wrap11(ActivityThread.java)在android.os.Looper.loop(Looper.java:148)atandroid.app.ActivityThread.main(ActivityThread.java:5459)at java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:728)at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)}

回答(2)

2 years ago

As james montemagno mentioned

您必须将目标版本设置为API 23并针对API 23进行编译:

enter image description here

2 years ago

在ANDROID N部分检查您使用的库的读物(正如Grace Feng在上面的评论中所述) .