Xamarin MediaPlugin和不同的Android版本

时间:2017-07-31 13:53:02

标签: c# xamarin xamarin.android xamarin.forms prism

我遇到Media Plugin的问题。 如果编译目标是Android 6.0,它在我的设备的调试模式下工作正常,即V. 5.0.1。问题是,当我在发布模式下编译时,我收到此错误:

> Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Android.Views.KeyboardShortcutGroup' (defined in assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Views.KeyboardShortcutGroup
   in Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   in MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   in Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance)
   in Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type)
   in Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
   in MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
   in Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
   in Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
   in Mono.Linker.Steps.MarkStep.ProcessQueue()
   in Mono.Linker.Steps.MarkStep.Process()
   in Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   in MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
   in Mono.Linker.Pipeline.Process(LinkContext context)
   in MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
   in Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)

read如果我将编译版本更新到Android 7(API 24),问题就解决了,但在此之后我的操作按钮不能正常工作。当我点击按钮打开相机时,我收到此错误:

Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference

我能做什么?谢谢!

1 个答案:

答案 0 :(得分:0)

我想我找到了一个解决方案: 我打开了AndroidManifest.xml文件,删除了android目标版本属性。

现在我只有:

Android编译版:7.1 Android miminal版本:4.1