Docs

Creative Kit Android

Requirements

To share any files with Snapchat, your app must target the right Android support library:

  • Android support library 22+

Getting Started

We share the Creative Kit and Core Kit AARs from our Maven repository. To access them, add the following to your root project's build.gradle file:

1
2
3
4
5
repositories {
   maven {
       url "https://storage.googleapis.com/snap-kit-build/maven"
   }
}

Note: If you have trouble accessing Google (used in the link above), you can use our GitHub Maven repository with the following code block:

1
2
3
4
5
repositories {
   maven {
       url "https://raw.githubusercontent.com/Snap-Kit/release-maven/repo"
   }
}

Next, add the following implementation to the dependencies section of your application’s build.gradle file, not the root project’s build.gradle:

1
2
3
4
5
6
7
dependencies {
   ...
   implementation([
           'com.snapchat.kit.sdk:creative:1.8',
           'com.snapchat.kit.sdk:core:1.8'
   ])
}

Set up your application’s AndroidManifest.xml:

1
2
3
4
5
6
<application ...>
   <!-- Please put your client id here -->
   <meta-data android:name="com.snapchat.kit.sdk.clientId" android:value="your app’s client id" />

   <!-- See below in the next section for how to setup FileProvider -->
</application>

If your app targets Android 11 (API level 30) or higher, you will need to include the following package query in your app's AndroidManifest.xml:

1
2
3
<queries>
  <package android:name="com.snapchat.android" />
</queries>

Set up your FileProvider to share media files to Snapchat.

To share any media or sticker content to Snapchat, follow the protocol specified by FileProvider API. Once you have set this up, your AndroidManifest.xml will contain the following under <application>:

1
2
3
4
5
6
7
8
9
10
        <provider
            android:authorities="${applicationId}.fileprovider"
            android:name="android.support.v4.content.FileProvider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"
                />
        </provider>

Note: The authority used by the SDK is explicitly <your-package-name>.fileprovider. Please ensure you follow this convention when setting the value. If you have different package names for debug and production builds, the ${applicationId} should resolve to it appropriately.


As of v1.4.4, Snap Kit is supported on x86 automatically. To filter out the x86 libraries, include the following snippet in your app's build.gradle:

1
2
3
4
5
defaultConfig {
  ndk {
    abiFilters 'armeabi-v7a', 'arm64-v8a'
  }
}

For older versions, to support Snap Kit on x86 and x86_64, include the following snippet in your app's build.gradle:

1
2
3
4
5
6
configurations.all {
    resolutionStrategy {
        force 'com.snapchat.kit.sdk:core:' + <versionName> + ' x86'

        }
} // Where <versionName> is the Snap Kit version you are using (Minimum 1.2.0)

Features

Preparing a Photo or Video to Send to Snapchat

A Snap with a still image or video is displayed in Snapchat’s preview screen, where the user can make the final modifications before sending it. Similarly, a Snap without any pre-populated content is displayed in Snapchat’s camera screen, letting users create their own content in a regular Snapchat flow. In both cases, your app can add metadata or overlays — like caption text, sticker images, and attachment URLs — to embed with the Snap.

This section explains how to use Creative Kit’s interfaces to let your users send to Snapchat.

Media Size and Length Restrictions
  • Shared media must be 100 MB or smaller.
  • Videos must be 60 seconds or shorter.

Suggested Media Parameters:

  • Aspect ratio - 9:16
  • Preferred file types:
    • Image - .jpg or .png
    • Video - .mp4
  • Dimensions - 1080px x 1920px
  • Video Bitrate - 1080p at 8mbps or 720p at 5mbps

A basic call:

1
2
3
SnapCreativeKitApi snapCreativeKitApi = SnapCreative.getApi(<Your-Activity>);
SnapMediaFactory snapMediaFactory = SnapCreative.getMediaFactory(<Your-Activity>);
snapCreativeKitApi.send(<Your-content>); // See below for examples

How your actual calls will look depends on your content. To provide still images for users to send to Snapchat, specify the photo content:

1
2
3
4
5
6
7
8
9
10
SnapMediaFactory snapMediaFactory = SnapCreative.getMediaFactory(<Your-Activity>);
SnapPhotoFile photoFile;
try {
   photoFile = snapMediaFactory.getSnapPhotoFromFile(<Your-photo-file>);
} catch (SnapMediaSizeException e) {
   handleError(e);
   return;
}
SnapPhotoContent snapPhotoContent = new SnapPhotoContent(photoFile);
snapCreativeKitApi.send(snapPhotoContent);

To provide videos for your users to send to Snapchat, specify the video content:

1
2
3
4
5
6
7
8
9
10
SnapMediaFactory snapMediaFactory = SnapCreative.getMediaFactory(<Your-Activity>);
SnapVideoFile videoFile;
try {
   videoFile = snapMediaFactory.getSnapVideoFromFile(<Your-video-file>);
} catch (SnapMediaSizeException|SnapVideoLengthException e) {
   handleError(e);
   return;
}
SnapVideoContent snapVideoContent = new SnapVideoContent(videoFile)
snapCreativeKitApi.send(snapVideoContent);

Or send your users right into the live camera on Snapchat:

1
SnapLiveCameraContent snapLiveCameraContent = new SnapLiveCameraContent();

Sharing With Overlay Stickers, Caption Text, and Attachment URLs

You can add sticker overlays, caption text, and attachment URLs to any Snap content type — including when deeplinking to the live camera.

Limitations
  • Stickers must be JPEG or PNG 1 MB or smaller.
  • Android currently does not support animated stickers.
  • Universal links are not supported

For stickers specifically, you can set the size, rotation, and placement position. Here’s an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SnapSticker snapSticker = null;
try {
    snapSticker = snapMediaFactory.getSnapStickerFromFile(stickerFile);
} catch (SnapStickerSizeException e) {
    handleError(e);
    return;
}
// Height and width~~ ~~in pixels
snapSticker.setWidth(300);
snapSticker.setHeight(300);

// Position is specified as a ratio between 0 & 1 to place the center of the sticker
snapSticker.setPosX(0.5f);
snapSticker.setPosY(0.5f);

// Specify clockwise rotation desired
snapSticker.setRotationDegreesClockwise(0); // degrees clockwise
<your-snap-content>.setSnapSticker(snapSticker);
// Note: Your snap content can be video, photo, or live-camera content

Provide captions for your users to easily add, letting their friends find your website directly from the Snap. Here’s how to add captions and URLs:

1
2
3
4
5
6
7
8
9
SnapCreativeKitApi snapCreativeKitApi = new SnapCreativeKitApi(<your-activity>, CLIENT_ID);
// Shows up as a caption text on top of the Snap
// User will be able to edit the vertical position in Preview screen
<snapContent>.setCaptionText(<your-caption-text>);

// The viewer of your Snap can swipe up to open this URL
<snapContent>.setAttachmentUrl(<your-website-url>);

snapCreativeKitApi.send(cameraPreviewSnapContent);

Adding a Lens Attachment

You are able to add Lens attachments so that users will open Snapchat to specific Lenses! To enable sharing with Dynamic Lenses, you must first create and publish a Lens using Lens Studio. When you initiate a share, you will need to point to the Lens using SnapLensContent. Dynamic fields can be populated using key-value pairs in SnapLensLaunchData. You can choose to add captions or a URL attachment to a Lens, but stickers and background photos or videos are disabled in this flow. In addition, you may optionally include launch data with the Lens attachment, to add other attributes to the Lens, like hints, for example.

Conditions

  • Stickers are not allowed
  • Captions are limited to 250 characters
  • The attachment URL must be a properly formatted URL in string format
  • Universal links are not supported
  • Launch data can be added in key-value pairs. The key must be a string and the value can be an int, float, double, string, or an array of any one of those types

Try the following for adding a Lens attachment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Build SnapLensLaunchData
SnapLensLaunchData launchData = new SnapLensLaunchData.Builder()
    .addStringKeyPair("hair_color", "#b76e79")
    .addStringKeyPair("hint", "lens_hint_raise_your_eyebrows")
    .build();

// Create a SnapLensContent object with SnapLensLaunchData and LensUUID to be shared
SnapLensContent snapLensContent = SnapLensContent.createSnapLensContent("123e4567e89b12d3a456426614174000", launchData);

// Optionally build SnapLensLaunchData, add to snapLensContent
SnapLensLaunchData launchData = new SnapLensLaunchData.Builder()
    .addStringKeyPair("hair_color", "#b76e79")
    .addStringKeyPair("hint", "lens_hint_raise_your_eyebrows")
    .build();

// Optionally add an attachmentUrl and caption to the content
snapLensContent.setAttachmentUrl("https://snapchat.com");
snapLensContent.setCaptionText("Check out this Snap Kit Lens!");

// Use the SnapCreative API to share the snapLensContent
SnapCreativeKitApi snapCreativeKitApi = SnapCreative.getApi(context);
snapCreativeKitApi.send(snapLensContent);

That’s it! You just learned how to integrate the Snapchat experience into your app.


Known Issues on Android

Animated and WebP stickers are not yet supported.


What’s Next