Airport Guides 2.0 is now available on Android!

Airport Guides 2.0 is now available on Android – it’s free, check it out!

When I stop and think about it, I’m not sure why I keep this project up. I published the first Xamarin.Forms Android version 5 years ago, and since then the Windows development experience for “modern” apps has gone through a lot of changes. Instead of trying to patch things forward I decided to make a fresh start with the UI code. (although things are still similar enough that it wasn’t nearly as hard as rewriting it)

And I think that was the right decision, but it’s irritating that the Portable Class Library I used isn’t really a thing anymore, and I already know what we’re using now is going to change when MAUI gets released. The Android emulator I’m using is slow (although not nearly as bad as it used to be, seems around 3x slower than a phone) and some things on it just don’t work. XAML Hot Reload is very nice, but sometimes the XAML changes don’t get recompiled or something, so every time I try something and it doesn’t work I have to guess whether I think I wrote the wrong code, or whether I wrote the right code and I should just rebuild the app. And I didn’t remember this from before, but you can get some pretty cryptic errors for common things:

  • If you use the wrong x:DataType on an element you get an InvalidCastException at runtime (fine) with no information about what you were trying to cast from and to! (not fine!)
  • Similarly a NullReferenceException I caused got converted to a TargetInvocationException with no information (because it was during navigation, I guess?)
  • I wasted a solid half hour on a cryptic XAML error “Content is set more than once” before desperately Binging and realizing that’s what you get when you have an extra “>” at the end of a XAML tag. *angry face*

It also has the irritating property that I need to periodically go through and update the maps for all 90 airports, which also has the “every day this app gets a little more out of date” feeling. And it’s not a big moneymaker, not that any of my apps are; we’re talking less than $50 a year.

And yet I poured a bunch of time over the last few weeks into this partial rewrite. I think there are a few reasons I’m drawn to the app:

  • Despite my complaints above, being able to write C# code (that I could conceivably port to iOS one day) for an Android app is pretty neat!
  • I really do like traveling, and airports, and maps, and looking at airport maps makes me happy.
  • I feel a sense of pride having apps that I wrote (I use my Baseball Odds app all the time!), and I’m looking forward to using this again when we travel.
  • I have a vague sense that having apps that are publicly available is good for my…brand? image? I dunno.

Anyway, it’s done now so I guess I should stop dithering. Give it a shot if you have an Android phone!

Android development makes me angry sometimes

So I’m working on making an Android version of my baseball win expectancy finder, and things are going pretty well! (anyone want to beta test it??) Except…

I’m using Xamarin.Forms so I can write all my code in C#/XAML, which is neat! I was even able to add Google ads in just an hour or two thanks to this handy guide after some fighting with NuGet packages.

Then I decided to build it in Release and deploy it to my actual phone, and it started to crash on launch. The Debug version didn’t have this problem, and launching the Release build through the debugger did not give any useful information, but after some Binging and fiddling with some project settings I managed to at least see that it was crashing with an Android.Views.InflateLayoutException. Sadly there was no data in the exception or call stack or anything.

So, OK, I figured there must be something with my XAML, so I commented out everything except the main TabbedPage control, but that didn’t help. At a loss, I went back to Bing and Google (yes, pulling out the big guns!) and after looking through a bunch of links and trying a handful of random things I looked more closely at the log and saw a line like

W/resourcetype: entry identifier 0x14c is larger than 0x84

So OK, this looks bad, I guess, and after some more Bing/Googling, I stumble across a this StackOverflow question that points to this Google Groups thread with a suggestion that this is a bug in “HistoryRecord over in the framework” (?) is trying to read the theme, and there isn’t anything wrong with your code. So I try this suggested workaround of adding this to the top of styles.xml:

<style name=”Stub”></style>
<style name=”Stub1″></style>
<style name=”Stub2″></style>
<style name=”Stub3″></style>
<style name=”Stub4″></style>
<style name=”Stub5″></style>
<style name=”Stub6″></style>

These don’t do anything, they’re just there to try to work around the bug.

This didn’t work, but I figured “in for a penny, in for a pound” and added a few more, which also didn’t work. Then I changed them to the self-terminating XML tag form <style name="Stub" /> and lo and behold, the crash went away!

The kicker? That Google Groups post was from 9 years ago. This bug, which causes a crash on startup with no obvious cause and requires a basically-impossible-to-guess workaround has been around for at least 9 years.

*incoherent muttering*

Airport Guides is now available for Android!

I’m happy to announce that Airport Guides (now with terminal maps for over 90 airports worldwide) is now available as a free app for Android! (the Windows 10 version is still available, too!)

Now that Xamarin is included for free with Visual Studio, I thought it would be fun to try it out. Xamarin lets you make apps for Windows/Android/iOS by writing code in C#. Usually you have to then design your UI in the appropriate language (Java for Android, Objective-C/Swift for iOS), but with Xamarin.Forms you can even write a cross-platform UI in C#!

Since most of the work in the Airport Guides app is maintaining the maps themselves, the app is pretty small so I thought it would be a good candidate for porting as opposed to something like Bridge Scorer which has a ton of custom UI. The experience was pretty good – writing the UI in Xamarin.Forms is a lot like writing it in UWP for Windows 10, except all the keywords are different 🙂

I did run into some frustrations along the way. One was not realizing that you can’t test in-app purchase stuff without a real device. (although in retrospect the documentation does mention this…somehow I missed it) Another was that while the Android emulator for Visual Studio is literally 10x faster than the default emulator, there’s at least one bug that doesn’t show up in the real emulator. For the record, it was fetching a particular web page that would always timeout…I still never figured out why! Pinch/zoom was also tricky to get working until someone pointed me to MR.Gestures (which I always pronounce “Mr. Gestures” in my head 🙂 ), but I still am disappointed that every platform doesn’t have an easy builtin way to make pinch/zoom on an image work. Shoutout to Alan Clark from Xamarin for helping me through some of these!