简体   繁体   中英

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:

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

I suspect that somehow a needed dll is not being loaded but don't know why. 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.

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.

It would seem that GooglePlayServices.dll was built against 4.10, while your app was packaged against 4.8 (which doesn't contain AllocObject() ). This would explain the MissingMethodException .

Xamarin.Android 4.10.1 is now stable; please upgrade.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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