在Xamarin.Android结合ESRI的ArcGIS的SDK [英] Binding ArcGIS Esri SDK in Xamarin.Android

查看:793
本文介绍了在Xamarin.Android结合ESRI的ArcGIS的SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在<一个href=\"http://forums.xamarin.com/discussion/856/help-wrapping-third-party-jar-for-mono-for-android/p1\"相对=nofollow>此线程上Xamarin论坛上,我发现说明 以及如何做一个 Java中的示例应用程序绑定库在Xamarin对ESRI公司的ArcGIS Android SDK中。

我下载的样本项目,并添加了10.1.1 ESRI 的.jar 文件和两个的.so 文件及在Visual Studio 2013设置的属性来在下面的括号指出的设置。我想双方的真实设备(三星S3)和谷歌仿真器(ARM)上运行此。

在根据核心项目的


  • ArcGIS_Android.jar(EmbeddedJar)

  • 杰克逊核心LGPL-1.9.5.jar(EmbeddedReferenceJar)

  • 杰克逊映射器,LGPL-1.9.5.jar(EmbeddedReferenceJar)

在根据Android项目的资产


  • armeabi \\ libruntimecore_java.so(And​​roidNativeLibrary)

  • armeabi-V7A \\ libruntimecore_java.so(And​​roidNativeLibrary)

我能够成功构建项目并运行它。的然而,它在运行时崩溃壮观当我尝试新的一个图形页面在MainActivity 的:

  VAR esriMap =新的图形页面(本);

如果我跟踪例外我能缩小它在图形页面构造这一行:

  JNIEnv.FinishCreateInstance(手柄,
                                 class_ref,
                                 id_ctor_Landroid_content_Context_,
                                 新JValue(P0));

我可以再跟踪异常到这里:

 内部静态的IntPtr class_ref
{
 {返回JNIEnv.FindClass(COM / ESRI /安卓/图/图形页面,楼盘java_class_handle); }
}

这是引发的异常:

我没有使用Android调试桥检查出的日志,这里是我的结果(过滤):

命令:亚行logcat MonoDroid的调试器:D MonoDroid的-GC:单声道D:W dalvikvm:W单RT:V *:•

  ---------的/ dev /日志/系统开始
---------中的/ dev /日志/主开始
W / MonoDroid的调试器(11905):试图初始化选项调试器:--debugger剂= =运输dt_socket,日志级别= 0,地址127.0.0.1 =:8839,服务器= Y,EMB
EDDING = 1
W / MonoDroid的调试器(11905):接受标准输出连接:50
W / MonoDroid的-GC(11905):GREF GC阈值:46800
W /单声道(11905):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W /单声道(11905):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W /单声道(11905):加载程序集System.Core程序v2.0.5.0请求被重新映射到v3.5.0.0
W /单声道(11905):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W /单声道(11905):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W / dalvikvm(11905):JNI警告:JNI方法调用异常挂起
W / dalvikvm(11905):在Ltestarcgisforandroid / MainActivity; .n_onCreate:(Landroid / OS /束;)V(的GetMethodID)
W / dalvikvm(11905):待定的例外是:
E / dalvikvm(11905):VM中止
E /单RT(11905):堆栈跟踪:
E /单RT(11905):
E /单RT(11905):AT&LT;&不明GT; &LT;&为0xffffffff GT;
E /单RT(11905):在(包装管理到本机)object.wrapper_native_0x40b2efd1(IntPtr的,IntPtr的,字符串,字符串)&LT; IL 0x0004c,为0xffffffff&GT;
E /单RT(11905):在(包装委托-调用)LT;模块&GT; .invoke_intptr__this ___ intptr_intptr_string_string(IntPtr的,IntPtr的,字符串,字符串)&LT; IL 0x00063,0​​XFFFFFF
FF&GT;
E /单RT(11905):在Android.Runtime.JNIEnv.GetMethodID(IntPtr的,字符串,字符串)[0x00042]在/Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a
1e3982a /来源/ MonoDroid的/ src目录/ Mono.Android / src目录/运行/ JNIEnv.g.cs:157
E /单RT(11905):在Java.Lang.Throwable.get_Message()[0x00014]在/Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroi
D / SRC / Mono.Android /平台/ Android的19 / src目录/生成/ Java.Lang.Throwable.cs:231
E /单RT(11905):在(封装运行时调用)LT;模块&GT; .runtime_invoke_object__this__(对象,IntPtr的,IntPtr的,IntPtr的)LT; IL 0x00050,为0xffffffff&GT;
E /单RT(11905):AT&LT;&不明GT; &LT;&为0xffffffff GT;
E /单RT(11905):在(包装动态法)object.60a3ae85-654e-4b68-b823-e9fd8b83b17b(IntPtr的,IntPtr的,IntPtr的)LT; IL 0x00034,0x000a8&GT;
E /单RT(11905):在(包装机设备到管理)object.60a3ae85-654e-4b68-b823-e9fd8b83b17b(IntPtr的,IntPtr的,IntPtr的)LT; IL 0x00023,为0xffffffff&GT;
E /单RT(11905):
E /单RT(11905):========================================= ========================
E /单RT(11905):执行本地code有一个SIGSEGV。这通常表明
E /单RT(11905):在单声道运行时一个致命的错误或本机库之一
E /单RT(11905):应用程序使用。
E /单RT(11905):========================================= ========================
E /单RT(11905):
W / MonoDroid的调试器(11961):试图初始化选项调试器:--debugger剂= =运输dt_socket,日志级别= 0,地址127.0.0.1 =:8839,服务器= Y,EMB
EDDING = 1
W / MonoDroid的调试器(11961):接受标准输出接口:-1
F / MonoDroid的调试器(11961):错误接受stdout和stderr(127.0.0.1:8840):地址已在使用
W / MonoDroid的调试器(11978):试图初始化选项调试器:--debugger剂= =运输dt_socket,日志级别= 0,地址127.0.0.1 =:8839,服务器= Y,EMB
EDDING = 1
W / MonoDroid的调试器(11978):接受标准输出接口:-1
F / MonoDroid的调试器(11978):错误接受stdout和stderr(127.0.0.1:8840):地址已在使用
W / dalvikvm(12023):VFY:无法解析虚方法505:Landroid /内容/上下文; .getExternalFilesDirs(Ljava /朗/字符串;)Ljava / IO /文件;
W / MonoDroid的调试器(12217):试图初始化选项调试器:--debugger剂= =运输dt_socket,日志级别= 0,地址127.0.0.1 =:8841,服务器= Y,EMB
EDDING = 1
W / MonoDroid的调试器(12217):接受标准输出连接:50
W / MonoDroid的-GC(12217):GREF GC阈值:46800
W /单声道(12217):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W /单声道(12217):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W /单声道(12217):加载程序集System.Core程序v2.0.5.0请求被重新映射到v3.5.0.0
W /单声道(12217):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0
W /单声道(12217):加载程序集mscorlib程序v2.0.5.0请求被重新映射到V2.0.0.0

我不知道我在做什么错了 - 我已经尝试运行/在两个Android的API级别17安培编写本; 19(样品的作者使用API​​等级17)。

我试着在Xamarin Studio中(而不是VS2013)上运行的解决方案,我得到了一个不同的异常:


  

在类名='requestRender'签名='(Z)V'都没法
  LCOM / ESRI /安卓/地图/ MapSurface;


下面的堆栈跟踪:

  Java.Lang.NoSuchMethodError:在课堂LCOM / ESRI /安卓/地图/ MapSurface名='requestRender'签名='(Z)V'没有一种方法;
  在Android.Runtime.JNIEnv.CallNonvirtualVoidMethod(IntPtr的,IntPtr的,IntPtr的,Android.Runtime.JValue [])[0x00084]中/Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:895
  在Android.Runtime.JNIEnv.FinishCreateInstance(IntPtr的,IntPtr的,IntPtr的,Android.Runtime.JValue [])[0x0000b]中/Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:272
  在Com.Esri.Android.Map.MapView..ctor(Android.Content.Context)[0x00109]中c:\\Workspace\\VisualStudio\\ArcGISForAndroid\\ArcGISForAndroid\\obj\\Debug\\generated\\src\\Com.Esri.Android.Map.MapView.cs:109
  在TestArcGISForAndroid.MainActivity.OnCreate(Android.OS.Bundle)[0x00026]在C:\\工作区\\ VisualStudio的\\ ArcGISForAndroid \\ TestArcGISForAndroid \\ MainActivity.cs:21
  在Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr的,IntPtr的,IntPtr的)[0x00011]中/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
  在在(包装动态法)object.26ff0a5e-0708-4e2c-8084-a668e6c87b45(IntPtr的,IntPtr的,IntPtr的)LT; IL 0x00017,0x00043&GT;
  在管理---异常堆栈跟踪的结尾---
  在java.lang.NoSuchMethodError:与NAME ='requestRender'类LCOM / ESRI /安卓/地图/ MapSurface签名='(Z)V'没有一种方法;
  在在com.esri.android.map.MapSurface.nativeMapCreate(本机方法)
  在在com.esri.android.map.MapSurface.a(来源不明)
  在在com.esri.android.map.MapSurface&LT;&初始化GT;(未知来源)
  在在com.esri.android.map.MapView.a(来源不明)
  在在com.esri.android.map.MapView&LT;&初始化GT;(未知来源)
  在在te​​starcgisforandroid.MainActivity.n_onCreate(本机方法)
  在在te​​starcgisforandroid.MainActivity.onCreate(MainActivity.java:28)
  在在android.app.Activity.performCreate(Activity.java:5372)
 在在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
  在在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
  在在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
  在在android.app.ActivityThread.access $ 700(ActivityThread.java:165)
  在在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1326)
  在在android.os.Handler.dispatchMessage(Handler.java:99)
  在在android.os.Looper.loop(Looper.java:137)
  在在android.app.ActivityThread.main(ActivityThread.java:5455)
  在在java.lang.reflect.Method.invokeNative(本机方法)
  在在java.lang.reflect.Method.invoke(Method.java:525)
  在在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1187)
  在在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
  在在dalvik.system.NativeStart.main(本机方法)


解决方案

需要libruntimecore_java.so添加到文件夹库\\ armeabi和库\\ armeabi,V7A
并将文件属性设置为AndroidNativeLibrary

它可以从日食的android项目文件夹复制库

In this thread on the Xamarin forums I found instructions and a sample application on how to make a Java Bindings Library in Xamarin for Esri's ArcGIS Android sdk.

I downloaded the sample project and added the 10.1.1 esri .jar files and the two .so files and set the properties in Visual Studio 2013 to the settings noted in the parenthesis below. I'm trying to run this on both a real device (Samsung S3) and the Google emulator(ARM).

In the Core project under Jars

  • ArcGIS_Android.jar (EmbeddedJar)
  • jackson-core-lgpl-1.9.5.jar (EmbeddedReferenceJar)
  • jackson-mapper-lgpl-1.9.5.jar (EmbeddedReferenceJar)

In the Android Project under Assets

  • armeabi\libruntimecore_java.so (AndroidNativeLibrary)
  • armeabi-v7a\libruntimecore_java.so (AndroidNativeLibrary)

I am able to successfully build the project and run it. However it crashes spectacularly at run time when I try to new up a MapView in the MainActivity:

var esriMap = new MapView(this);

If I trace the exception I'm able to narrow it down to this line in the MapView constructor:

    JNIEnv.FinishCreateInstance (Handle, 
                                 class_ref,
                                 id_ctor_Landroid_content_Context_, 
                                 new JValue (p0));

Which I can then trace the exception to here:

internal static IntPtr class_ref 
{
 get { return JNIEnv.FindClass ("com/esri/android/map/MapView", ref java_class_handle); }
}

This is the exception that is thrown:

I did use the Android Debug Bridge to check out the log and here are my results (filtered):

Command: 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

I'm not sure what I am doing wrong - I've tried running/compiling this at both Android API Levels 17 & 19 (the author of the sample used API Level 17).

I tried running the solution in Xamarin Studio (instead of VS2013) and I got a different exception:

no method with name='requestRender' signature='(Z)V' in class Lcom/esri/android/map/MapSurface;

Here's the stack trace:

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)

解决方案

need add libruntimecore_java.so to the folder libs\armeabi and libs\armeabi-v7a and set the file property to "AndroidNativeLibrary"

it can copy from eclipse android project folder libs

这篇关于在Xamarin.Android结合ESRI的ArcGIS的SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆