Disclaimer: this is an automatic aggregator which pulls feeds and comments from many blogs of contributors that have contributed to the Mono project. The contents of these blog entries do not necessarily reflect Xamarin's position.

June 22

Hackweek 2018 — The Unity way

At Unity, we’re out to democratize development by enabling success for creators. As Global R&D HR Director, I’m focused on nurturing our talented people to help attain that goal, and Hackweek’s a big part of that. This year’s event is our biggest ever and will include exciting new initiatives like Women in Gaming, onsite childcare, […]

June 21

Getting Android Apps Ready for Google Play’s Target API Level Requirements

Developing Android applications is a unique experience, as it often involves taking advantage of the latest capabilities of Android while still providing backward compatibility to older Android devices in order to reach all potential users. This feat is accomplishable by using Android support libraries and doing runtime checks while using the latest APIs in the application code.

Android uses two specific properties set in the AndroidManifest.xml through the project properties to determine how your application should run. Thus, it is important to fully understand how these Android API settings impact your application.

Starting this year, Google Play will roll out a new policy that impacts all Android developers submitting new apps and app updates. This blog post will ensure that your application is fully ready for these changes, which will require the targetSdkVersion to be set to Android 8.0 API level 26 or higher, when it goes into effect for new apps on August 1, 2018 and for app updates on November 1, 2018.

Understanding API Levels

As mentioned earlier Android applications have two very important attributes that must be set in the AndroidManifest.xml file:

  • Minimum Android Version (minSdkVersion): Specifies the oldest Android version that you want your app to support. This API level is used at runtime by Android.
  • Target Android Version (targetSdkVersion): Specifies the version of Android that your app is intended to run on. This API level is used at runtime by Android.

An example would be the following:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.App15.Android">
	<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
	<application android:label="App15.Android"></application>

The *uses-sdk* properties are used by the Android OS specifically to turn on or off features and by Google Play to determine what devices your application can run on. So for this example, the application can be installed on devices running Android 4.4 (KitKat API 19) and above, which is over 95% of all active Android devices. It also is informing Android that our application uses modern features of Android such as runtime permissions, adheres to background execution limits, and notification channels.

Google Play will require all applications to set the targetSdkVersion to API level 26 or higher so start testing today!

Update Compile (Target Framework) version

In addition to the two properties that are outlined above, there is one additional setting that must be updated for our application, which is the Compile framework. This is a specific Xamarin.Android property that is accessed in the Application properties that tells Xamarin.Android what Android framework to build the application against. This also impacts the APIs that you see when writing code inside of Visual Studio. When we right-click on an Android project and go to properties the Application settings will appear. It is recommended to use the latest version of Android (8.1 API 27 at the time of writing) and match both the Target SDK Version and Android support libraries versions, which we will see how to update later. This can be accomplished by simply setting the Compile using Android version: (Target Framework) property.

Do not worry if you do not have the Android 8.1 SDK installed. Easily install using the Android SDK Manager and installing Android SDK Platform 27:

This Target Framework is the equivalent of compileSdkVersion which informs aapt (Android Asset Packaging Tool) on what API level to use. This is why it is also important to update the Android Platform and Build tools to match your compilation target. This can be done from the Android SDK and Tools manager:

Update Target Android Version

Now, it is time to set the Target Android version which is what Google Play will start enforcing when submitting new apps and updates. Inside of the properties of the Android project, we will find the Android Manifest section which has both the Minimum and Target android versions.

IMPORTANT: These must be set to a specific version and cannot be set to “Use Compile Version”. Failure to set to a specific version number will result in the AndroidManifest.xml not getting the property assigned, which can cause several side effects.

To set it manually, simply select the same API Level of Android 8.1 (API Level 27 – Oreo) like so:

The Golden API Rule

All of these API and compile levels can get pretty confusing, but if you remember one thing it is the golden rule on how to set API levels:

minimumSdkVersion <= targetSdkVersion <= compileSdkVersion

Often this is even simplified because best practice is always to set the target and compile versions to the same. However, it is okay to have the targetSdkVersion set lower then the compileSdkVersion (Compile Target Framework).

Update Support Libraries

At this point, the app is ready to submit to Google Play and meets the new requirements, but we should also ensure that any Android support library is updated to the latest version. Android support libraries are versioned with the major number representing the version of Android SDK that it was compiled against, which means the latest version,, was compiled against Android SDK API 27 and is what our application should use. Opening the NuGet package manager will show us any Android support libraries that were installed that need to be updated. It is important to update all Android Support Libraries at the same time so they all match:

Handling NuGet Dependency API Level Conflicts

Most applications will also have additional libraries such as Xamarin.Essentials or third-party libraries that take a dependency on Android Support Libraries. If this is the case, ensure that you first manually add any of the Android Support Libraries to your Android project through NuGet before attempting to update all of them in your project. An example is Xamarin.Essentials which uses Xamarin.Android.Support.Core.Utils and Xamarin.Android.Support.CustomTabs. If these are not manually added to the project first you may see an error such as:

Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the project to resolve this issue. 
 App15.Android -> Xamarin.Android.Support.v7.MediaRouter -> Xamarin.Android.Support.v7.Palette -> Xamarin.Android.Support.Compat (= 
 App15.Android -> Xamarin.Essentials -> Xamarin.Android.Support.CustomTabs 27.0.2 -> Xamarin.Android.Support.Compat (= 27.0.2).

To get around the .csproj if using package references and at the same time manually update all support libraries to the latest version:

    <PackageReference Include="Xamarin.Essentials" Version="" />
    <PackageReference Include="Xamarin.Forms" Version="" />
    <PackageReference Include="Xamarin.Android.Support.Design" Version="" />
    <PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="" />
    <PackageReference Include="Xamarin.Android.Support.v4" Version="" />
    <PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="" />
    <PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="" />
    <PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="" />
    <PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="" />

If the project still uses package references simply add the packages manually and then update all of the support libraries. You will want to do this with any other NuGet libraries that you may have.

Learn More

Now your Android apps are up to date and ready for submission using the latest and greatest Android SDK and Support Libraries. To learn more about changes to Google Play requirements be sure to head over to the Android developer portal and for an in-depth overview of Android API level see our full documentation.

Have questions or comments? Discuss this post on the Xamarin forums!

The post Getting Android Apps Ready for Google Play’s Target API Level Requirements appeared first on Xamarin Blog.

Bringing connected games within reach with Google Cloud

At Unite Berlin, we announced a strategic alliance with Google Cloud. Together, we are building a suite of features that will help you create, run, and scale your connected games. In this post, I’ll share how we define connected games, what we have been working on with Google Cloud, and give you a peek at […]

June 20

Announcing Kinematica: Animation meets machine learning

For years, I’ve been working on a challenging question: what if you could create your game without worrying about building complex animation graphs? What if all that time setting up nested state machines, manually creating those transitions points, and matching poses could be spent instead on the art itself? We set out to create a […]

Introducing new Prefab workflows

One of the top requested additions to Unity is the ability to nest Prefabs. But we know a lot of you need many more changes to the Prefab workflows than that. Therefore, we’re improving the whole system with focus on reusability, control & safety. This is the first in a series of blog posts explaining […]

June 19

Connected games, facial mocap, New Prefabs workflow preview and more from Unite Berlin

We kicked off Unite Berlin today! We couldn’t be happier to finally share all of the exciting news that we’ve been working on, from our strategic alliance with Google Cloud to help you make connected games, to a preview build of our improved prefab system. Here’s your handy overview of all the keynote announcements. The […]

June 18

Unity ML-Agents Toolkit v0.4 and Udacity Deep Reinforcement Learning Nanodegree

We are happy to announce the release of the latest version of ML-Agents Toolkit: v0.4. It contains a number of features, which we hope everyone will enjoy. It includes the option to train your environments directly from the editor, rather than as built executables, making iteration time much quicker. In addition, we are introducing a […]

Supporting iOS 11 and iPhone X in Xamarin.iOS Apps

Apple has indicated that starting in July 2018 all new apps and app updates submitted to the App Store must be built with the iOS 11 SDK and support the iPhone X Super Retina display.

The following resources describe how to make sure Xamarin.iOS apps look and work great with iOS 11 and iPhone X:

Starting this July, be sure that all new apps and app updates that are submitted to the App Store include support for iOS 11 and iPhone X.

To discuss this post, head on over to the Xamarin Forums!

The post Supporting iOS 11 and iPhone X in Xamarin.iOS Apps appeared first on Xamarin Blog.

June 15

Book of the Dead: Photogrammetry Assets, Trees, VFX

In this blog series, we will go over every aspect of the creation of our demo “Book of the Dead”. Today, we focus on photogrammetry assets, trees and VFX. This is the fourth blog in the series, take a look back at the last two blogs that go through creating characters and concept art from […]

Multi-platform Handheld AR in 2018

We know that many of you are really excited about building handheld Augmented Reality (AR) apps. So we’ve developed a multi-platform API and utilities that will help you solve many of the hard problems that come with AR development. We call it AR Foundation. Unity has always been at the forefront of handheld AR development […]

June 14

More Cross-Platform APIs with Xamarin.Essentials Latest Preview

We announced Xamarin.Essentials, a core set of cross-platform APIs to help developers build native apps, at Microsoft Build 2018. Xamarin.Essentials gives developers access to over thirty platform-specific APIs that can be accessed from their shared code, including geolocation, secure storage, sensors, device information, and many more. Best of all, Xamarin.Essentials can be used in any iOS, Android, UWP, or Xamarin.Forms app, regardless of how you create the user interface. Feedback on the first preview from developers has been fantastic, with praise of a simple and straightforward way to access these native features.

Today, we are pleased to release our second preview of Xamarin.Essentials (0.7.0-preview), which is available today on NuGet. This release combines feedback from developers, bug fixes, and several new APIs that you can take advantage of today.

Orientation Sensor

Xamarin.Essentials first release gave developers access to the accelerometer, gyroscope, magnetometer, and compass. Based on your feedback, we’ve added an API for the orientation sensor. This API allows you to subscribe to reading changes that are reported back as a Quaternion, which describes rotation of the Earth’s coordinate system relative to the device’s coordinate system. This is extremely useful when creating applications that need access to 3D space.

public class OrientationSensorTest
    // Set speed delay for monitoring changes.
    SensorSpeed speed = SensorSpeed.Ui;

    public OrientationSensorTest()
        // Register for reading changes, be sure to unsubscribe when finished
        OrientationSensor.ReadingChanged += OrientationSensor_ReadingChanged;

    void OrientationSensor_ReadingChanged(AccelerometerChangedEventArgs e)
        var data = e.Reading;
        Console.WriteLine($"Reading: X: {data.Orientation.X}, Y: {data.Orientation.Y}, Z: {data.Orientation.Z}, W: {data.Orientation.W}");
        // Process Orientation quaternion (X, Y, Z, and W)

    public void ToggleOrientationSensor()
            if (OrientationSensor.IsMonitoring)
        catch (FeatureNotSupportedException fnsEx)
            // Feature not supported on device
        catch (Exception ex)
            // Other error has occurred.

Platform APIs

When developing applications that process information in the background, it’s important to update the user interface on the main thread. With the Platform API, you now have access to detect if you’re currently on the main thread and also begin an update on the main thread. We use this API internally to optimize our own code in Xamarin.Essentials.

using Xamarin.Essentials;

public class MyViewModel
    public bool UpdateUI()
        Platform.BeginInvokeOnMainThread(() =>
            // Ensure invoked on MainThread. Xamarin.Essentials will optimize this and check if you are already on the main thread

    public bool ProcessInformation()
            // Start new thread to process on background
            // Already on non-main thread.

Simplified Android Dependencies

Based on your feedback, Xamarin.Essentials is now built against Android 8.1 (API 27), with the updated dependencies of two Android Support libraries, CustomTabs and Core.Utils. This means you will need to ensure you have your Xamarin.Android project set to compile against Android 8.1 (API 27), which you can set in the properties of your project.

Remember, it’s important to have the saved version of all Android Support libraries in your project; now is a good time to update all of your dependencies in your project.

Xamarin.Essentials In Action

Ready to learn more about Xamarin.Essentials? Look no further than the latest Xamarin Show: Snack Pack, which gives a full overview of Xamarin.Essentials and how to start integrating it into your app.

Learn More

Read more about this release in our full release notes and be sure to browse through our full documentation, which has a full overview of how to get started and how to use every feature of Xamarin.Essentials.

The post More Cross-Platform APIs with Xamarin.Essentials Latest Preview appeared first on Xamarin Blog.

What’s new in Unity ARKit Plugin for ARKit 2

Apple announced exciting news for AR developers last week at WWDC, including ARKit 2. Unity has worked closely with Apple to allow our developers instant access to all of these new features with an update to Unity ARKit Plugin. In this blog, we’ll get into the technical details of ARKit 2’s new features and how […]

June 13

Case Study: A game for conflict-affected youth to learn and grow

Unity enables the creation of a huge range of games and experiences, including innovative tools for learning and training.  These range from powerful medical simulations to games that help kids learn critical skills like reading and mathematics by making these subjects engaging and playful. We want to take a moment to highlight a powerful example […]

June 12

Use MongoDB With Your Xamarin Apps

One of the most important decisions that you’ll make when designing an app is what type of database to use.

Not too long ago, the choice was limited to relational databases like SQL server. However, now NoSQL databases are on the scene with the benefits of allowing applications to handle large amounts of structured and unstructured data at the same time, the ability to easily model data as objects, and massively scale across servers.

MongoDB is a NoSQL database that stores documents in a binary JSON format that has been popular in the Node.js community for a while. Azure Cosmos DB is a fully managed cloud database. With just a few clicks you can configure a database that is 100% compatible with the MongoDB API. 

Despite the popularity of MongoDB for Node.js solution, a fully supported and maintained driver for .NET exists. The driver is implemented in .NET Standard which means it is compatible with multiple platforms, including Xamarin. 

This article will show you how to create your first Xamarin app using MongoDB! We’ll query data using LINQ, insert, and delete data. By the end of this article you’ll have the info you need to create MongoDB powered Xamarin apps yourself.

You can find all of the code for a demo app in this GitHub repo.

Set Up the Environment

For the purposes of this tutorial, our MongoDB will be hosted in Azure Cosmos DB.

First, to get your instance of Azure Cosmos DB set up and ready to use, follow the instructions on the Azure Cosmos DB documentation page. Create a free Azure account using this link if you don’t already have one set up.

The MongoDB.NET library enables the communication between Xamarin apps and the MongoDB. Search for MongoDB.Driver using the NuGet Package Manager in Visual Studio or Visual Studio for Mac and dd that library to all of your projects.

Connect to MongoDB

Next, our app needs to connect to the MongoDB. Use the MongoClient object to obtain a reference to the IMongoDatabase . Then use the IMongoDatabase object to obtain a reference to the IMongoCollection<T> class. (See the demo project for an example of this connection code.)

To understand the connection process, it helps to understand how MongoDB arranges its data.

The Azure Cosmos DB account created above is the first level of organization. One or more databases sit under the account. Then one or more collections comprise a database. The last level, documents, reside within a collection.

Cosmos DB MongoDB API Data Structure

To read and write documents, our app will use the IMongoCollection<T> class. Where the generic is our model, or a strongly typed representation of the document.

Query Data

We use IMongoCollection<T> to query the documents in the collection. In mobile applications it is important to query asynchronously to avoid blocking the UI thread and provide a better user experience. A great feature of .NET is LINQ queries. LINQ helps developers write complex query statements in an easy to understand syntax, fortunately the MongoDB driver as full support for LINQ queries.

The code to return every document in a collection looks like the following:

public async Task<List<ToDoItem>> GetAllItems()
    var allItems = await ToDoItemsCollection
        .Find(new BsonDocument())

    return allItems;

One thing to note from above is the BsonDocument in the  Find function. That indicates an empty filter, and is needed to return any documents.

If the collection contains thousands of documents, or we want to filter documents, we should use a different query.

This query filters on name and also only returns the first 10 records.

public async Task<List<ToDoItem>> SearchByName(string name)
    var results = await ToDoItemsCollection
                    .Where(tdi => tdi.Name.Contains(name))

    return results;

The AsQueryable() extension provides an interface that supports LINQ extensions and makes it possible to leverage filters, skip and take statements, etc.

Write Data

The MongoDB .NET library also provides a simple asynchronous data modification API.

Inserting data looks like this:

public async Task InsertItem(ToDoItem item)
    await ToDoItemsCollection.InsertOneAsync(item);

To replace the entire document with a single update use the following code:

public async Task UpdateItem(ToDoItem item)
    await ToDoItemsCollection.ReplaceOneAsync(tdi => tdi.Id == item.Id, item);

The MongoDB driver defines attributes to provide additional information when they are used to decorate classes and properties. For example, the  [BsonId]  attribute specifies which property on the class should be used as the unique key or identifier for tat instance/document.

Summing Up

MongoDB is a well known and widely used document database. The combination of Azure Cosmos DB and the .NET MongoDB driver makes it a viable solutions for Xamarin apps that should ideally feel familiar to .NET mobile developers.

To learn more about MongoDB, see the documentation here. Read more about Cosmos DB with MongoDB here. Give the demo app a test drive here!


And, as always, please feel free to discuss this post in the forums!

The post Use MongoDB With Your Xamarin Apps appeared first on Xamarin Blog.

Unite Berlin 2018: What to expect next week

Unite Berlin kicks off on June 19. That’s only one week away, and we can’t wait to meet many of you at all the sessions, networking opportunities and more! Can’t attend this year? Make sure you join us online by tuning into our keynote and select session livestreams! Don’t miss out on one of the […]

June 11

PostFX v2 – Amazing visuals, upgraded

The Post-Processing Stack makes it easy to create and fine-tune high-quality visuals for dramatic and realistic effect. Coming out of beta in 2018.1, we’ve added the most requested features and have fixed as many bugs as possible. We’ve also added mobile-specific paths, volume blending, and a complete framework for custom user-effects. Version 2 (v2) of […]


Monologue is a window into the world, work, and lives of the community members and developers that make up the Mono Project, which is a free cross-platform development environment used primarily on Linux.

If you would rather follow Monologue using a newsreader, we provide the following feed:

RSS 2.0 Feed

Monologue is powered by Mono and the Monologue software.