与OsmDroid的Monodroid Jar绑定问题

时间:2013-01-16 17:46:18

标签: mono xamarin.android porting osmdroid

我正在尝试从OsmDroid(3.0.9-SNAPSHOT:http://code.google.com/p/osmdroid/source/browse/)移植主干版本。以前我使用xamarin示例移植3.0.8版本。在版本3.0.9中,我遇到了一个错误,所以我真的需要移植OsmDroid的主干版本。

我现在遇到三个错误:

Error CS0535: 'OsmDroid.Views.SafeCanvas.SafeTranslatedCanvas' does not implement interface member 'OsmDroid.Views.SafeCanvas.ISafeCanvas.DrawColor(int)' (CS0535) (OsmDroid)
Error CS0535: 'OsmDroid.Views.SafeCanvas.SafeTranslatedCanvas' does not implement interface member 'OsmDroid.Views.SafeCanvas.ISafeCanvas.DrawColor(int, Android.Graphics.PorterDuff.Mode)' (CS0535) (OsmDroid)
Error CS0535: 'OsmDroid.Views.SafeCanvas.SafeTranslatedCanvas' does not implement interface member 'OsmDroid.Views.SafeCanvas.ISafeCanvas.Save(int)' (CS0535) (OsmDroid)

据我所知,这三个缺少的界面成员是Android.Canvas的成员。生成可移植代码后,这三种方法不会移植,但在原始jar文件(SafeTranslatedCanvas.javaISafeCanvas.java)中可见。

如何在Metadata.xml中解决这些问题?

提前致谢。 问候, faiko

2 个答案:

答案 0 :(得分:1)

我设法通过添加部分类来编译osmdroid 3.0.9(& 3.0.10):

using Android.Graphics;

namespace Org.Osmdroid.Views.Safecanvas
{
    partial class SafeTranslatedCanvas
    {
        public void DrawColor(int color)
        {
            this.WrappedCanvas.DrawColor(new Color(color));
        }

        public void DrawColor(int color, Android.Graphics.PorterDuff.Mode mode)
        {
            this.WrappedCanvas.DrawColor(new Color(color), mode);
        }

        public int Save(int SaveFlags)
        {
            return this.WrappedCanvas.Save((Android.Graphics.SaveFlags)SaveFlags);
        }
    }
}

我还必须解决另外两个与可见性相关的错误:

Error   30  'OsmDroid.Views.Overlay.SafeDrawOverlay.Draw(Android.Graphics.Canvas, OsmDroid.Views.MapView, bool)': cannot change access modifiers when overriding 'public' inherited member 'OsmDroid.Views.Overlay.Overlay.Draw(Android.Graphics.Canvas, OsmDroid.Views.MapView, bool)' C:\Users\K\Desktop\LodzKieruje\LodzKieruje\OsmDroidBinding\obj\Debug\generated\src\OsmDroid.Views.Overlay.SafeDrawOverlay.cs    111 27  OsmDroid
Error   34  'OsmDroid.Views.Overlay.ScaleBarOverlay.DrawSafe(Org.Osmdroid.Views.Safecanvas.ISafeCanvas, OsmDroid.Views.MapView, bool)': cannot change access modifiers when overriding 'protected' inherited member 'OsmDroid.Views.Overlay.SafeDrawOverlay.DrawSafe(Org.Osmdroid.Views.Safecanvas.ISafeCanvas, OsmDroid.Views.MapView, bool)'  C:\Users\K\Desktop\LodzKieruje\LodzKieruje\OsmDroidBinding\obj\Debug\generated\src\OsmDroid.Views.Overlay.ScaleBarOverlay.cs    388 24  OsmDroid

通过向Metadata.xml添加以下行来解决这个问题

  <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='SafeDrawOverlay']/method[@name='draw']" name="visibility">public</attr>
  <attr path="/api/package[@name='org.osmdroid.views.overlay']/class[@name='ScaleBarOverlay']/method[@name='drawSafe']" name="visibility">protected</attr>

我的项目现在启动并且地图可见但是它没有响应 - 它不会缩放也不会滚动。我想知道你是否会有同样的结果。

答案 1 :(得分:0)

您是否看过包含OsmDroid样本的Xamarin Sample repository