Building your first Camera Kit App
Camera Kit brings Snap's cutting-edge augmented reality technology to your mobile, desktop and web applications. In this tutorial, you'll learn how to build an Android-based Camera Kit application, allowing you to apply a Lens to the user's camera.
Prerequisites
- Basic knowledge of Kotlin and Android View based layouts.
- Latest version of Android Studio installed.
- Familiarity with CameraX for camera app development.
Download & unzip the project files above and open the root folder Android Starter Project/
directory in Android Studio

Update Configuration and initialize Camera Kit
We'll start by adding our credentials: API Token, Lens ID, Lens Group ID. Then we'll create a CameraXImageProcessorSource to display the camera feed.
Open AndroidManifest.xml
and update your API token
This can be found in My Lenses and will be used to initialize Camera Kit.
Open CameraViewActivity.kt
and update your Lens group ID and Lens ID
These can also be found in My Lenses and will be used to fetch lenses.
Ensure that Camera Kit is supported on this device
This is a precaution, we show a simple popup(Toast
) if the device is not supported.
Initialize the Image processor source
The CameraXImageProcessorSource
is supplying the Camera Feed to the CameraKit SDK.
Create a function to start the camera preview
This method allows us to start the camera preview from the front camera (true
paramater).
Import Classes and Initialize Permission Launcher
Import the required classes for handling a camera permission request and then register a permission request launcher that prompts the user for camera access. If granted, proceed to start the camera preview.
Check Camera Permission and Start Preview
We must request the permission at runtime in onCreate
. We use ContextCompat
to check if the camera permission is granted. If granted, proceed to start the camera preview. If not, launch the permission request to prompt the user for access.
Import Camera Kit Session
and Invoke
then declare the Session object
The Session object is the main entry point for Camera Kit. It's responsible for managing Lens and AR functionality in your app.
Initialize Camera Kit Session
Set up a Session for the Camera Kit, configuring it with an image processor and attaching it to the layout view.

Applying a Lens
Now that you have a feed running, this section will guide you through applying a Lens to your live video feed.
Setup Observer and query lens
Create an observer on the lenses repository, we search for a specific lens using its ID and group ID, and recieve real-time updates based on the query results.
Apply requested lens!
We get the first lens from the result and apply it to the lens processor for that session.
Close the Camera Kit Session in Activity onDestroy
This function ensures that the Camera Kit session is properly closed when the activity is destroyed, freeing up resources and preventing potential memory leaks.