mail-archives/monodroid/2011-December/007556.html

234 строки
14 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [mono-android] New Mono for Android release does not work with some samples on GitHub
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20New%20Mono%20for%20Android%20release%20does%20not%20work%20with%0A%20some%20samples%20on%20GitHub&In-Reply-To=CACWcBbkjivo7arYtaEJyMHgBJ-_A2d7wN6qAERmG_AzYTksrOg%40mail.gmail.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="007555.html">
<LINK REL="Next" HREF="007566.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[mono-android] New Mono for Android release does not work with some samples on GitHub</H1>
<B>Tomasz Cielecki</B>
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20New%20Mono%20for%20Android%20release%20does%20not%20work%20with%0A%20some%20samples%20on%20GitHub&In-Reply-To=CACWcBbkjivo7arYtaEJyMHgBJ-_A2d7wN6qAERmG_AzYTksrOg%40mail.gmail.com"
TITLE="[mono-android] New Mono for Android release does not work with some samples on GitHub">tomasz at ostebaronen.dk
</A><BR>
<I>Tue Dec 6 07:48:41 EST 2011</I>
<P><UL>
<LI>Previous message: <A HREF="007555.html">[mono-android] New Mono for Android release does not work with some samples on GitHub
</A></li>
<LI>Next message: <A HREF="007566.html">[mono-android] New Mono for Android release does not work with some samples on GitHub
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#7556">[ date ]</a>
<a href="thread.html#7556">[ thread ]</a>
<a href="subject.html#7556">[ subject ]</a>
<a href="author.html#7556">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Or wait I was a bit quick there.
Give me a moment and I will make a test project for you to see what is
happening.
On Tue, Dec 6, 2011 at 1:45 PM, Tomasz Cielecki &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">tomasz at ostebaronen.dk</A>&gt; wrote:
&gt;<i> OK, that seems a bit strange to me. Your suggestion works though. I
</I>&gt;<i> would have though that the OverlayItem would explicitly be
</I>&gt;<i> implementing Java.Lang.Object rather than just Object so that it would
</I>&gt;<i> be unambiguous.
</I>&gt;<i>
</I>&gt;<i> Maybe someone should make a note about this somewhere so that people
</I>&gt;<i> do not make the same mistake as I did.
</I>&gt;<i>
</I>&gt;<i> On Tue, Dec 6, 2011 at 1:35 PM, Atsushi Eno
</I>&gt;<i> &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">atsushieno at veritas-vos-liberabit.com</A>&gt; wrote:
</I>&gt;&gt;<i> Ah, no that's not a bug :)
</I>&gt;&gt;<i> You likely have &quot;using System;&quot; on top of your source and that binds
</I>&gt;&gt;<i> &quot;Object&quot; class to System.Object type. Unlike &quot;java.lang&quot; package for
</I>&gt;&gt;<i> Java compilers, C# compiler does not import &quot;Java.Lang&quot; by default, so
</I>&gt;&gt;<i> you have to explicitly write &quot;using Java.Lang;&quot; .
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> However, if you do that, C# compiler will error it out because &quot;Object&quot;
</I>&gt;&gt;<i> name is now ambiguous between &quot;System.Object&quot; and &quot;Java.Lang.Object&quot;.
</I>&gt;&gt;<i> So, you will either have to give up using &quot;using&quot; statement or add
</I>&gt;&gt;<i> explicit declaration that &quot;using Object = Java.Lang.Object;&quot; .
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Atsushi Eno
</I>&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> So the OverlayItem is having the using Java.Lang; in the top of the
</I>&gt;&gt;&gt;<i> file and is implementing Object, but then the compiler thinks it is
</I>&gt;&gt;&gt;<i> System.Object rather than Java.Lang.Object. I guess this is a bug that
</I>&gt;&gt;&gt;<i> you will have to correct.
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> Meanwhile I am just using
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> protected override Java.Lang.Object CreateItem(int index)
</I>&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;{
</I>&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160; &#160; &#160;return overlayItems.ElementAt(index);
</I>&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;}
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> Which seems to work fine.
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> I have created a bug report: <A HREF="http://bugzilla.xamarin.com/show_bug.cgi?id=2358">http://bugzilla.xamarin.com/show_bug.cgi?id=2358</A>
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i> On Tue, Dec 6, 2011 at 11:55 AM, Atsushi Eno
</I>&gt;&gt;&gt;<i> &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">atsushieno at veritas-vos-liberabit.com</A>&gt; &#160;wrote:
</I>&gt;&gt;&gt;&gt;<i> Yes, as the error message tells, it must be derived from Java.Lang.Object.
</I>&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;<i> Atsushi Eno
</I>&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;<i> Is this because Overlay item is inheriting from System.Object rather
</I>&gt;&gt;&gt;&gt;&gt;<i> than Java.Lang.Object?
</I>&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160;public class OverlayItem : Object
</I>&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;<i> On Tue, Dec 6, 2011 at 9:45 AM, Tomasz Cielecki&lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">tomasz at ostebaronen.dk</A>&gt; &#160; &#160;wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> I get the same error even if CreateItem returns OverlayItem. So
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> something is wrong somewhere.
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> On Tue, Dec 6, 2011 at 9:43 AM, Tomasz Cielecki&lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">tomasz at ostebaronen.dk</A>&gt; &#160; &#160;wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> OK. About that OverlayItem. I have a Custom overlay item which looks like this:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160;class NMTOverlayItem : OverlayItem
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160;{
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;private float[] color;
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;public NMTOverlayItem(GeoPoint point, String title, String
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> snippet, float[] color)
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160; &#160; &#160;: base(point, title, snippet)
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;{
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;this.color = color;
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;}
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;public float[] Color
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;{
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160; &#160; &#160;get { return color; }
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;}
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160;}
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Now in the itenized overlay I have the CreateItem method:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;protected override NMTOverlayItem CreateItem(int index)
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;{
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160; &#160; &#160;return overlayItems.ElementAt(index);
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160; &#160; &#160; &#160;}
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> I get the following error:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 'NSPublic.AndroidClient.NMTItemizedOverlay.CreateItem(int)': return
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> type must be 'Java.Lang.Object' to match overridden member
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> 'Android.GoogleMaps.ItemizedOverlay.CreateItem(int)'
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Any ideas as to why this is happening?
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> On Mon, Dec 5, 2011 at 6:52 PM, Tomasz Cielecki&lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">tomasz at ostebaronen.dk</A>&gt; &#160; &#160;wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Awesome, will give it a go tomorrow :-)
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> As always good job on the new release!
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> On Dec 5, 2011 5:38 PM, &quot;Jonathan Pryor&quot;&lt;<A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">jonp at xamarin.com</A>&gt; &#160; &#160;wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> On Dec 5, 2011, at 11:25 AM, Tomasz Cielecki wrote:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Due to changes to how sensors work, i.e. stuff being moved into
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> SensorTypes the samples on GitHub do not work anymore.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Changes needed to get the samples working with the new release were done
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> on the release-2-0 branch, which was just merged to master ~10 minutes ago.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Please update your repo and see if that fixes it. :-)
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Also there has been some changes in the ItemizedOverlay now having the
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> CreateItem method registered, but it needs to return a
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Java.Lang.Object, does that mean that my custom OverlayItem has to
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> inherit from Java.Lang.Object? I thought OverlayItem was already a
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Java.Lang.Object?
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> OverlayItem inherits Java.Lang.Object, so your class inheriting from
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> OverlayItem will also inherit Java.Lang.Object, just not directly.
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Subclassing OverlayItem is fine (and required, iirc).
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Is there a list of changes made in the newest release somewhere?
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://android.xamarin.com/Releases/Mono_for_Android_4/Release_4.0.0#API_Changes">http://android.xamarin.com/Releases/Mono_for_Android_4/Release_4.0.0#API_Changes</A>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> &#160; &#160;- Jon
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Monodroid mailing list
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> --
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Med Venlig Hilsen / With Best Regards
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> Tomasz Cielecki
</I>&gt;&gt;&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://ostebaronen.dk">http://ostebaronen.dk</A>
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> --
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> Med Venlig Hilsen / With Best Regards
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> Tomasz Cielecki
</I>&gt;&gt;&gt;&gt;&gt;&gt;<i> <A HREF="http://ostebaronen.dk">http://ostebaronen.dk</A>
</I>&gt;&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;&gt;&gt;<i> Monodroid mailing list
</I>&gt;&gt;&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;&gt;&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;<i> Monodroid mailing list
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">Monodroid at lists.ximian.com</A>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> UNSUBSCRIBE INFORMATION:
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/monodroid">http://lists.ximian.com/mailman/listinfo/monodroid</A>
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i> --
</I>&gt;<i> Med Venlig Hilsen / With Best Regards
</I>&gt;<i> Tomasz Cielecki
</I>&gt;<i> <A HREF="http://ostebaronen.dk">http://ostebaronen.dk</A>
</I>
--
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
<A HREF="http://ostebaronen.dk">http://ostebaronen.dk</A>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="007555.html">[mono-android] New Mono for Android release does not work with some samples on GitHub
</A></li>
<LI>Next message: <A HREF="007566.html">[mono-android] New Mono for Android release does not work with some samples on GitHub
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#7556">[ date ]</a>
<a href="thread.html#7556">[ thread ]</a>
<a href="subject.html#7556">[ subject ]</a>
<a href="author.html#7556">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/monodroid">More information about the Monodroid
mailing list</a><br>
</body></html>