【发布时间】:2014-05-30 07:36:18
【问题描述】:
在 Xamarin 论坛上的 this thread 中,我找到了 instructions 和 sample application,了解如何在 Xamarin 中为 Esri 的 ArcGIS Android sdk 制作 Java 绑定库。
我下载了示例项目并添加了 10.1.1 esri .jar 文件和两个 .so 文件,并将 Visual Studio 2013 中的属性设置为下面括号中注明的设置。我正在尝试在真实设备(三星 S3)和谷歌模拟器(ARM)上运行它。
在Jars下的Core项目中
- ArcGIS_Android.jar (EmbeddedJar)
- jackson-core-lgpl-1.9.5.jar (EmbeddedReferenceJar)
- jackson-mapper-lgpl-1.9.5.jar (EmbeddedReferenceJar)
在 Assets
下的 Android 项目中- armeabi\libruntimecore_java.so (AndroidNativeLibrary)
- armeabi-v7a\libruntimecore_java.so (AndroidNativeLibrary)
我能够成功构建项目并运行它。 但是,当我尝试在 MainActivity 中新建 MapView 时,它在运行时崩溃了:
var esriMap = new MapView(this);
如果我跟踪异常,我可以在 MapView 构造函数中将其缩小到这一行:
JNIEnv.FinishCreateInstance (Handle,
class_ref,
id_ctor_Landroid_content_Context_,
new JValue (p0));
然后我可以将异常追踪到这里:
internal static IntPtr class_ref
{
get { return JNIEnv.FindClass ("com/esri/android/map/MapView", ref java_class_handle); }
}
这是抛出的异常:
我确实使用了 Android Debug Bridge 来检查日志,这是我的结果(过滤后的):
命令:adb logcat MonoDroid-Debugger:D monodroid-gc:D Mono:W dalvikvm:W mono-rt:V *:S
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
W/MonoDroid-Debugger(11905): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8839,server=y,emb
edding=1
W/MonoDroid-Debugger(11905): Accepted stdout connection: 50
W/monodroid-gc(11905): GREF GC Threshold: 46800
W/Mono (11905): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/Mono (11905): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/Mono (11905): The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0
W/Mono (11905): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/Mono (11905): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/dalvikvm(11905): JNI WARNING: JNI method called with exception pending
W/dalvikvm(11905): in Ltestarcgisforandroid/MainActivity;.n_onCreate:(Landroid/os/Bundle;)V (GetMethodID)
W/dalvikvm(11905): Pending exception is:
E/dalvikvm(11905): VM aborting
E/mono-rt (11905): Stacktrace:
E/mono-rt (11905):
E/mono-rt (11905): at <unknown> <0xffffffff>
E/mono-rt (11905): at (wrapper managed-to-native) object.wrapper_native_0x40b2efd1 (intptr,intptr,string,string) <IL 0x0004c, 0xffffffff>
E/mono-rt (11905): at (wrapper delegate-invoke) <Module>.invoke_intptr__this___intptr_intptr_string_string (intptr,intptr,string,string) <IL 0x00063, 0xffffff
ff>
E/mono-rt (11905): at Android.Runtime.JNIEnv.GetMethodID (intptr,string,string) [0x00042] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a
1e3982a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:157
E/mono-rt (11905): at Java.Lang.Throwable.get_Message () [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroi
d/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.Throwable.cs:231
E/mono-rt (11905): at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
E/mono-rt (11905): at <unknown> <0xffffffff>
E/mono-rt (11905): at (wrapper dynamic-method) object.60a3ae85-654e-4b68-b823-e9fd8b83b17b (intptr,intptr,intptr) <IL 0x00034, 0x000a8>
E/mono-rt (11905): at (wrapper native-to-managed) object.60a3ae85-654e-4b68-b823-e9fd8b83b17b (intptr,intptr,intptr) <IL 0x00023, 0xffffffff>
E/mono-rt (11905):
E/mono-rt (11905): =================================================================
E/mono-rt (11905): Got a SIGSEGV while executing native code. This usually indicates
E/mono-rt (11905): a fatal error in the mono runtime or one of the native libraries
E/mono-rt (11905): used by your application.
E/mono-rt (11905): =================================================================
E/mono-rt (11905):
W/MonoDroid-Debugger(11961): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8839,server=y,emb
edding=1
W/MonoDroid-Debugger(11961): Accepted stdout connection: -1
F/MonoDroid-Debugger(11961): Error accepting stdout and stderr (127.0.0.1:8840): Address already in use
W/MonoDroid-Debugger(11978): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8839,server=y,emb
edding=1
W/MonoDroid-Debugger(11978): Accepted stdout connection: -1
F/MonoDroid-Debugger(11978): Error accepting stdout and stderr (127.0.0.1:8840): Address already in use
W/dalvikvm(12023): VFY: unable to resolve virtual method 505: Landroid/content/Context;.getExternalFilesDirs (Ljava/lang/String;)[Ljava/io/File;
W/MonoDroid-Debugger(12217): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8841,server=y,emb
edding=1
W/MonoDroid-Debugger(12217): Accepted stdout connection: 50
W/monodroid-gc(12217): GREF GC Threshold: 46800
W/Mono (12217): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/Mono (12217): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/Mono (12217): The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0
W/Mono (12217): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
W/Mono (12217): The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
我不确定我做错了什么 - 我已经尝试在 Android API 级别 17 和 19 上运行/编译它(示例的作者使用 API 级别 17)。
我尝试在 Xamarin Studio(而不是 VS2013)中运行该解决方案,但遇到了不同的异常:
类中没有 name='requestRender' signature='(Z)V' 的方法 lcom/esri/android/map/MapSurface;
这是堆栈跟踪:
Java.Lang.NoSuchMethodError: no method with name='requestRender' signature='(Z)V' in class Lcom/esri/android/map/MapSurface;
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:895
at Android.Runtime.JNIEnv.FinishCreateInstance (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x0000b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:272
at Com.Esri.Android.Map.MapView..ctor (Android.Content.Context) [0x00109] in c:\Workspace\VisualStudio\ArcGISForAndroid\ArcGISForAndroid\obj\Debug\generated\src\Com.Esri.Android.Map.MapView.cs:109
at TestArcGISForAndroid.MainActivity.OnCreate (Android.OS.Bundle) [0x00026] in c:\Workspace\VisualStudio\ArcGISForAndroid\TestArcGISForAndroid\MainActivity.cs:21
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/platforms/android-17/src/generated/Android.App.Activity.cs:2119
at at (wrapper dynamic-method) object.26ff0a5e-0708-4e2c-8084-a668e6c87b45 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
at --- End of managed exception stack trace ---
at java.lang.NoSuchMethodError: no method with name='requestRender' signature='(Z)V' in class Lcom/esri/android/map/MapSurface;
at at com.esri.android.map.MapSurface.nativeMapCreate(Native Method)
at at com.esri.android.map.MapSurface.a(Unknown Source)
at at com.esri.android.map.MapSurface.<init>(Unknown Source)
at at com.esri.android.map.MapView.a(Unknown Source)
at at com.esri.android.map.MapView.<init>(Unknown Source)
at at testarcgisforandroid.MainActivity.n_onCreate(Native Method)
at at testarcgisforandroid.MainActivity.onCreate(MainActivity.java:28)
at at android.app.Activity.performCreate(Activity.java:5372)
at at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
at at android.app.ActivityThread.access$700(ActivityThread.java:165)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
at at android.os.Handler.dispatchMessage(Handler.java:99)
at at android.os.Looper.loop(Looper.java:137)
at at android.app.ActivityThread.main(ActivityThread.java:5455)
at at java.lang.reflect.Method.invokeNative(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:525)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at at dalvik.system.NativeStart.main(Native Method)
【问题讨论】:
-
你能解决这个问题吗?如果可以,请您发布解决方案。
-
不,从未解决。我们正在等待 ESRI 发布 Xamarin 绑定。