Programming

Creating a Xamarin Binding Library & iOS 11.2

When creating and compiling the Binding Library by following the guide provided by Xamarin, and having set your iOS SDK to 11.2, you will most likely find that armv7 is no longer supported when executing the Makefile:

To solve this issue, simply remove the support for armv7 as done below (remember to use tabs if you write the Makefile by hand):

Now you should be able to produce the Fat binaries.

// Dave

Standard
Programming

Application Loader, Xamarin and GoogleCast v3 Binding Library

I recently had to upload a new version of an Xamarin.iOS application and used the Application Loader to do so. The difference between the previous and new version  of the application was that the new one included a Binding Library for Google ChromeCast v3.

When I tried to upload, I got the following error:

I spent days tracking down the issue by both reading the official documentation and forums. By sheer luck, I tried uploading using the Organizer in XCode. To my surprise, the application was successfully uploaded to iTunes Connect and started processing. Although, after some time, I received a mail stating that:

[…] The app’s Info.plist must contain an NSBluetoothPeripheralUsageDescription key with a string value explaining to the user how the app uses this data.

Looking at the documentation, it was quite clear that I indeed had forgotten to define the NSBluetoothPeripheralUsageDescription key.

After resolving the issue, I tried uploading using the Application Loader. Unfortunately, the same issue occurred. Instead, I used the Organizer in XCode, and this time, the application was uploaded and processing completed. What a relief!

Lessons learned

Seemingly, the Application Loader doesn’t handle Binding Libraries from Xamarin.iOS that well when they are included as a Framework. Going forward, I’ll instead use the Organizer in XCode for publishing.

I am although certain that other developers will stumble upon this issue as well. Conclusively, Apple should either consider resolving the issue with the Application Loader or remove it from the market entirely.

Standard
Programming, Xamarin.Forms, Xamarin.Forms.Android

Obtaining a Google Maps API Key

I recently observed an issue when debugging my Xamarin.Forms.Android solution which uses Xamarin.FormsMaps in two different development environments.

The problem was, that I received an error stating that I was missing authentication with the Google Maps API in only one development environment.

Solving the issue

This guide assumes that you have already succesfully established a connection with the Google Maps API in at least one development environment. If you havn’t already worked with Xamarin.FormsMaps before, here is a guide on how to get started, and here is a detailed list of the required permissions in your Android project.

Anywho, on to the issue at hand:

  1. First, obtain the SHA1 fingerprint from your debug key by following this guide
    1. While you’re at it, grab the SHA1 fingerprint for your release key as well by following the same process, but by select the certificate you use for release
  2. Open the Google Developers Console
  3. Select your project and navigate to “APIs & auth” => “Credentials”
  4. In here, click “Edit allowed Android applications”
  5. For each key you have (I’ve got 3 in total: 2 development enviroments, and 1 release certifcate) add a new line with the following contents:
    1. <SHA1-fingerprint>;com.your.packagename
  6. Click “Update”

By now, your “Key for Android applications” should resemble that of the screenshot below. If it does, the Google Maps API has been succesfully registered with both your development and release certficates.

Android SHA1 Fingerprints

Android SHA1 Fingerprints

// Dave

Standard
Programming

Json.NET crashes when releasing an Xamarin.Android Application

So, after I published my last post, some users reported that the Android app I’m developing didn’t contain any content.

This seemed weird to me, as I knew for a fact, that the iOS version worked just fine.

Fortunately, I am using Xamarin.Insights, which allows me to monitor issues that may arise.

Apperently, the users whom had installed the Android app experienced a lack of content due to a JSON serialization issue which meant that no data was shown – ofcourse, this should be handled by presenting an error message in the UI as well.

The reason was, apparently, that Json.NET crashes in release mode under Xamarin.Android, but not when debugging, which is why I didn’t initially experience the issue myself.

The solution

What you need to do if you experience this issue is to follow these simple steps:

  1. In Visual Studio / Xamarin Studio, right click on your Android project and select “Properties”
  2. Go to “Android Options” => “Linker”
  3. In the field “Skip linking assemblies” enter “System.Core” (without the quotes)
    1. Note: if you have already omitted other assemblies, seperate them using “;” (quotes omitted)
  4. Save

Now, you can release your Android app once more without having Json.NET crashing.’

Testing the solution

If you want to be sure that the solution works before publishing your app to the Google Play Store, you can:

  1. Set your “Solution Configuration” to “Release”
  2. In Visual Studio, open the “Debug” menu
  3. Now click “Start Without Debugging”

Doing so allows the application to be installed in release-mode on your emulator/device.

// Dave

Standard