簡體   English   中英

引用Google Maps類時缺少方法異常

[英]Missing method exception when referencing Google Maps class

當我嘗試使用Android.Gms.Maps.Model.Marker類實例化一個Dictionary時,我得到一個System.MissingMethodException ,如下所示:

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

我懷疑某個所需的dll沒有被加載但不知道為什么。 這個問題似乎特定於我的特定開發環境,因為具有相同代碼的其他開發人員沒有看到此問題。 我可以在Genymotion,華碩平板電腦和運行Android 4.2.2的GS4中重現這個問題。

應用程序輸出報告以下內容

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

這是堆棧跟蹤:

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()是添加到Xamarin.Android 4.10.1的方法。

似乎GooglePlayServices.dll是針對4.10構建的,而您的應用程序是針對4.8(不包含AllocObject() )打包的。 這將解釋MissingMethodException

Xamarin.Android 4.10.1現在穩定; 請升級。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM