# Setup

## Share

Sharing content using Facebook Share helper is easier than anything else, but before that there are a few things that needs to be done.

* Open your main **AndroidManifest.xml** file in **Assets/Plugins/Android/** folder and add this code inside tag:

```xml
<provider
     android:name="androidx.core.content.FileProvider"
     android:authorities="com.package.name.fileprovider"
     android:exported="false"
     android:grantUriPermissions="true">
     <meta-data
           android:name="android.support.FILE_PROVIDER_PATHS"
           android:resource="@xml/file_paths"/>
</provider>
```

Where **com.package.name** is the package name of your application.

* Add this permission if it's not already included in your AndroidManifest.xml file:

```xml
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
```

* Last but not least add \<queries> tag inside your manifest file:

```xml
<queries>
   <package android:name="com.facebook.katana" />
</queries>
```

Here is a sample AndroidManifest.xml file:

```xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">
    <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />

    <queries>
        <package android:name="com.facebook.katana" />
    </queries>

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">

        <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
            <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
        </activity>

        <provider android:name="androidx.core.content.FileProvider" android:authorities="com.hardartcore.TikTokShare.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/>
        </provider>

    </application>
</manifest>
```

And after the setup is complete you can use the helper class as:

```csharp
public class DemoSceneScript : MonoBehaviour
{
    public FacebookStoryShareHelper facebookStoryShareHelper;

    // Share image to Facebook Story by providing the path to the image file
    public void ShareImageToStory()
    {
        facebookStoryShareHelper.ShareImageToFacebookStory(_imageFilePath);
    }

    // Share image & sticker to Facebook Story by providing file paths
    public void ShareImageAndStickerToStory()
    {
        facebookStoryShareHelper.ShareImageWithStickerToFacebookStory(_imageFilePath, _stickerFilePath);
    }

    // Share image with gradient to Facebook Story by providing file paths and color values
    public void ShareImageWithGradientToStory()
    {
        facebookStoryShareHelper.ShareStickerWithGradientToFacebookStory(_imageFilePath, "#CC3322", "#99AE32");
    }
    // Share video to Facebook Story by providing file path
    public void ShareVideo()
    {
        facebookStoryShareHelper.ShareVideoToFacebookStory(_videoFilePath);
    }

    // Share video & sticker to Facebook Story by providing file paths
    public void ShareVideoWithSticker()
    {
        facebookStoryShareHelper.ShareVideoWithStickerToFacebookStory(_videoFilePath, _stickerFilePath);
    }

    // Share video to Facebook Reel by providing file path
    public void ShareVideoReel()
    {
        facebookStoryShareHelper.ShareVideoReel(_videoFilePath);
    }

    // Share video & sticker to Facebook Reel by providing file path
    public void ShareVideoReelWithSticker()
    {
        facebookStoryShareHelper.ShareVideoReelWithSticker(_videoFilePath, _stickerFilePath);
    }

}
```

## Build Errors

If you encounter an issue: **`unexpected element <queries> found in <manifest>`**

There is an easy fix for that: go to **File** -> **Build Settings** -> **Player Settings** -> **Publishing Settings** and select **Custom Base Gradle Template**. After that open the generated file **baseProjectTemplate.gradle** under **Assets/Plugins/Android** folder and change `com.android.tools.build:gradle:***` to&#x20;

**Unity 2019.4**+ -> `com.android.tools.build:gradle:3.4.3`

**Unity 2021.3+** -> `com.android.tools.build:gradle:4.0.1`
