Java.Lang.NoSuchMethodError: 找不到非静态方法"Landroid/content/Context;.getColorStateList(I)Landroid/content/res/ColorStateList;"

4

查看我的日志

Java.Lang.NoSuchMethodError: no non-static method "Landroid/content/Context;.getColorStateList(I)Landroid/content/res/ColorStateList;"
01-11 12:48:49.249 I/MonoDroid( 9688):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 
01-11 12:48:49.249 I/MonoDroid( 9688):   at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in <3cb12bce834a498199b2be6cd3e00922>:0 
01-11 12:48:49.249 I/MonoDroid( 9688):   at Java.Interop.JniType.GetInstanceMethod (System.String name, System.String signature) [0x0000c] in <3cb12bce834a498199b2be6cd3e00922>:0 
01-11 12:48:49.249 I/MonoDroid( 9688):   at Java.Interop.JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember) [0x00031] in <3cb12bce834a498199b2be6cd3e00922>:0 
01-11 12:48:49.249 I/MonoDroid( 9688):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00006] in <3cb12bce834a498199b2be6cd3e00922>:0 
01-11 12:48:49.249 I/MonoDroid( 9688):   at Android.Content.Context.GetColorStateList (System.Int32 id) [0x00022] in <551e90b840814b76a3d15b7bbaa8a77c>:0 
01-11 12:48:49.249 I/MonoDroid( 9688):   at Movo.MapActivity+<OnCreate>d__37.MoveNext () [0x000a6] in C:\Users\MapActivity.cs:85 An unhandled exception occured.
1个回答

6

在API Level 23中添加了基于ContextGetColorStateList方法,因此如果您尝试在旧版Android上执行该方法,它将失败。

现在,在com.android.support:support-compat(版本24.1+)中(通过Xamarin Nuget Xamarin.Android.Support.Compat),有一个基于ContextCompatGetColorStateList可以用于旧版(和新版)API级别。


你能否详细说明一下?我需要在我的VS项目中做哪些更改才能使其在API Level 21上运行?这是一个全新的 MAUI Blazor 应用程序。 - ILIA BROUDNO

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接