> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/collaboration/collab/setup-a.md).

# Setting up realtime document collaboration in Xamarin

Learn how to integrate Apryse core and tools library in Xamarin.Android with this step-by-step tutorial. Prerequisites include Minimum API 21 and Java 8. Visual Studio 2019 is required for compilation

{% hint style="info" %}
**This tutorial only applies to Xamarin.Android.**
{% endhint %}

## Prerequisites

* Minimum API: 21
* Java 8

To compile for Java 8, add the following to your application's `.csproj` file:

**Visual Studio 2019 is required**

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
<PropertyGroup>
  <AndroidEnableDesugar>true</AndroidEnableDesugar>
  <AndroidDexTool>d8</AndroidDexTool>
</PropertyGroup>
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Step 1: Integration

1. Integrate Apryse core and the tools library as described in [Xamarin get started guide](/xamarin/get-started/xamarin-android/integrate-android.md#integrate-manually).
2. Open the NuGet package manager by right click on your project, and click **Manage NuGet Packages...**. Then in **Browse** tab, search for Apryse.

Insall:

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-c6eee95070dfb5376fe825ec8b872e156a17dc47%2F6d833e0afcd4d20d5438856f7d436a460851b035-800x75.png?alt=media)

## Step 2: Add the viewer

1. Update your `AndroidManifest.xml` as described in **Step 1** of [this guide](https://docs.apryse.com/xamarin/collaboration/collab/pages/al9b7EBzqCmR4WnZOiAx#step-1:-update-androidmanifestxml).
2. Create the `CollabViewerTabHostFragment2`, and start it like any other Android Fragment.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
private void addViewerFragment(AppCompatActivity activity, Android.Net.Uri fileUri)
{
    // Create a custom ViewerConfig used to initialize the viewer fragment
    var viewerConfig = new ViewerConfig.Builder()
        .MultiTabEnabled(false)
        .OpenUrlCachePath(this.CacheDir.AbsolutePath)
        .Build();
    // Create the Fragment using CollabViewerBuilder2
    var tabHostFragment = (CollabViewerTabHostFragment2)CollabViewerBuilder2
        .WithUri(fileUri)
        .UsingConfig(viewerConfig)
        .Build(this);
    // Add the Fragment to your activity
    var ft = activity.SupportFragmentManager.BeginTransaction();
    ft.Replace(Resource.Id.fragment_container, tabHostFragment, null);
    ft.Commit();
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

where `R.id.fragment_container` is the resource id of a layout in your activity that will contain your fragment:

**For example:**

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<?xml version="1.0" encoding="utf-8"?>
<!-- This FrameLayout will contain our viewer fragment -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent"/>
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Next steps

* [Connect with annotation database](/xamarin/collaboration/server.md#android)
* [Customize collaboration UI](/xamarin/collaboration/client.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/collaboration/collab/setup-a.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
