简体   繁体   English

引用Google Maps类时缺少方法异常

[英]Missing method exception when referencing Google Maps class

I'm getting a System.MissingMethodException when I try to instantiate a Dictionary using the Android.Gms.Maps.Model.Marker class as follows: 当我尝试使用Android.Gms.Maps.Model.Marker类实例化一个Dictionary时,我得到一个System.MissingMethodException ,如下所示:

Dictionary<Marker, MyInnerClass> _markers = new Dictionary<Marker, MyInnerClass>();

I suspect that somehow a needed dll is not being loaded but don't know why. 我怀疑某个所需的dll没有被加载但不知道为什么。 The problem seems to be specific to my specific dev environment since other developers with the same code are not seeing this problem. 这个问题似乎特定于我的特定开发环境,因为具有相同代码的其他开发人员没有看到此问题。 I can reproduce the issue in Genymotion, an Asus Tablet and a GS4 all running Android 4.2.2. 我可以在Genymotion,华硕平板电脑和运行Android 4.2.2的GS4中重现这个问题。

Application output reports the following: 应用程序输出报告以下内容

[] Missing method Android.Runtime.JNIEnv::AllocObject(Type) in assembly Mono.Android.dll, referenced in assembly GooglePlayServices.dll

Here's the stack trace: 这是堆栈跟踪:

System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.AllocObject'.
at MyProduct.Maps.MyMapFragment..ctor () [0x00013] in /Users/me/code/my.domain/MyProduct/Maps/MyMapFragment.cs:48
at at (wrapper dynamic-method) object.ffa689fb-fdde-4e08-abd8-3bdf6ae641fb (intptr,object[]) <IL 0x00018, 0x00037>
at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:141
at at (wrapper native-to-managed) Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) <IL 0x00020, 0x0007f>
at at (wrapper managed-to-native) object.wrapper_native_0xb65e0e20 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00003>
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:612
at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:3824
at MyProduct.MyListActivity.OnCreate (Android.OS.Bundle) [0x00079] in /Users/me/code/my.domain/MyProduct/MyListActivity.cs:83
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1937
at at (wrapper dynamic-method) object.24a01956-09ee-4dec-9155-eff468f7249c (intptr,intptr,intptr) <IL 0x00017, 0x0001f>

Android.Runtime.JNIEnv.AllocObject() is a method that was added to Xamarin.Android 4.10.1. Android.Runtime.JNIEnv.AllocObject()是添加到Xamarin.Android 4.10.1的方法。

It would seem that GooglePlayServices.dll was built against 4.10, while your app was packaged against 4.8 (which doesn't contain AllocObject() ). 似乎GooglePlayServices.dll是针对4.10构建的,而您的应用程序是针对4.8(不包含AllocObject() )打包的。 This would explain the MissingMethodException . 这将解释MissingMethodException

Xamarin.Android 4.10.1 is now stable; Xamarin.Android 4.10.1现在稳定; please upgrade. 请升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM