Quick Start Guide

Follow this guide to set up a project for Xamarin.Android in order to easily implement the Anyline SDK.

The Xamarin Bundle

The Xamarin SDK Bundle that you can download from github contains the following parts for you to get started in Xamarin:

  • BindingSource - Xamarin iOS and Android Binding Libraries, including wrappers
  • Examples - Xamarin.iOS and Xamarin.Android example apps
  • AnylineXamarinSDK.Droid.dll - Precompiled library for Xamarin.Android
  • AnylineXamarinSDK.iOS.dll - Precompiled library for Xamarin.iOS
  • AnylineResources.Bundle - The iOS Resource files that have to be included to your app project as BundleResource (iOS only!)
  • AT.Anyline.Xamarin.App.Droid_<version>.apk - Prebuilt Android APK ready to install on your Android device
  • README.md - A short readme about the Anyline Xamarin Examples bundle.
  • LICENSE.md - The license file.


To use the Anyline SDK for Xamarin.Android you need:

  • A Xamarin account (If you work with Visual Studio, you need at least a Xamarin business account. Check out the Xamarin Website for detailed information)
  • An Android device with SDK >= 18
  • Decent camera functionality (recommended: 720p and adequate auto focus)
  • Xamarin Studio or Visual Studio as an IDE


In this section we will go through the basic process of creating and configuring a simple Anyline scanning application in Xamarin.Android. If you are not yet familiar with Xamarin.Android, follow the Official Xamarin Android Quickstart Guide to develop an understanding of the fundamentals of Android application development with Xamarin.

Create a new Xamarin.Android Project

If you are using Visual Studio, click File > New Project…, select Visual C# > Android and create a new Blank App.

Create a Xamarin Android Project in Visual Studio

If you are using Xamarin Studio, click New Solution… and create an Android App.

Create a Xamarin Android Project in Xamarin Studio

Generate an Anyline License Key

In order to run the Anyline SDK in your app, you require a license key.

In order to create a license key for your application, you have to identify the applicationId of your Xamarin.Android app.

License <> ApplicationId

Every license is bound to an applicationId. If you change your applicationId, you will require a new license. This also ensures that your license key cannot be used in any other application.

How to identify the Application ID

To generate a license key for your application, refer to the package name of your Xamarin.Android project

Identify the Application ID in Visual Studio Identify the Application ID in Xamarin Studio

Generate the License

With the applicationId you are now able to Generate a License

Once you generated your license key for the package name of your app, you can integrate it as follows:

Integrate the License Key

In order to integrate your generated license key, you can either add the license key as string to your .cs code-behind of your scanning activity, or create a string resource under ResourcesValuesStrings.xml and reference it.

In your C# code-behind
// in your scanning Activity class:

public const string LicenseKey = "INSERT_YOUR_LICENSE_KEY_HERE";

// in the OnCreate() cycle:

// Initialize with our license key and our result listener
scanView.InitAnyline(LicenseKey, this);
From a resource string
        <string name="license_key">YOUR_LICENSE_KEY</string>

Your license key can then be accessed in the InitAnyline() method.

// Initialize with our license key and our result listener
scanView.InitAnyline(Resource.String.license_key, this);

Add AnylineXamarinSDK.Droid as reference

To access the functionality of our SDK, simply add the AnylineXamarinSDK.Droid.dll file as a reference.

Visual Studio

  • Right-click the References node in your project tree
  • Click Add reference…
  • Click Browse… and locate the AnylineXamarinSDK.Droid.dll file

Xamarin Studio

  • Right-click the References node in your project tree
  • Click Edit references…
  • Navigate to the .Net Assembly tab
  • Click Browse… and locate the AnylineXamarinSDK.Droid.dll file

The SDK should now be visible as a reference and your project tree should somewhat look like this:

The Anyline SDK in the Xamarin project tree

Set minimum Android target

In the Application settings of your project, set the minimum version of your Android target to API level 17.

The Android API Level in your Xamarin Project

Add necessary permissions and features

The scanning activity needs the following permissions and features:

  • Permissions
    • CAMERA
  • Features
    • android.hardware.camera
    • android.hardware.camera.flash
    • android.hardware.camera.autofocus

This is how you can add them to your AndroidManifest.xml in your Properties node:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="AT.Anyline.Xamarin.App.Droid" android:versionCode="1" android:versionName="1.0" android:installLocation="preferExternal">
        <uses-sdk />
  <!--add android:hardwareAccelerated="true" for Camera2 API support-->
  <application android:label="Anyline Examples (Xamarin.Android)" android:icon="@drawable/ic_launcher" android:theme="@style/AppTheme"
        <!--add this for simultaneous barcode scanning-->
        <meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="barcode" />
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.VIBRATE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <uses-feature android:name="android.hardware.camera" android:required="false" />
        <uses-feature android:name="android.hardware.camera.flash" />
        <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

Camera API & Hardware Acceleration

Since newer devices might use the Android Camera2 API, it’s important to make sure that hardware acceleration is enabled in the activity that implements Anyline. This can be set as seen above through the AndroidManifest, but better yet it should be set directly in the C# code of the activity like so: [Activity(Label = "My Activity", HardwareAccelerated = true)]

In the next section, we will implement a Scan View and provide a configuration to customize both visual parameters and behaviours.