Skip to main content

Getting Started

Build rich Augmented Reality experiences for Android.

Overview

DeepAR is an augmented reality SDK used to integrate advanced, Snapchat-like face lenses in iOS, Android and Web apps.

DeepAR Android supports:

  • Face filters and masks.
  • Glasses virtual try on.
  • Background replacement.
  • Background blur.
  • AR mini-games.

Support

  • DeepAR is supported on Android Marshmallow 6.0 (API level 23) and above.
  • For Android 12 and above, see the section Android 12+.

Quickstart project

See the official example here.

Install

DeepAR is available as AAR dependency installed via maven server or can be downloaded directly from DeepAR Developer Portal.

Gradle

Add DeepAR maven server as remote repository in your Android gradle project: https://sdk.developer.deepar.ai/maven-android-repository/releases/

By default, new Android Studio projects specify Google's Maven repository, and the Maven central repository as repository locations in the project's settings.gradle. Add to that DeepAR maven server.

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
maven {
url "https://sdk.developer.deepar.ai/maven-android-repository/releases/"
}
}

To add a DeepAR dependency to your project, specify a implementation dependency in the dependencies block of your module's build.gradle file.

dependencies {
implementation 'ai.deepar.ar:DeepAR:5.3.0'
}

Direct download

  1. Download the Android package from DeepAR Developer Portal and unzip.
  2. Create the libs directory in you Android Studio project and copy the deepar.aar in that directory.
  3. In the build.gradle speficy the implementation dependency in the dependencies block.
dependencies {
implementation files('libs/deepar.aar')
}

You can read more about adding dependencies to Android Studio projects here.

License key

In order to use the DeepAR SDK you need to set up a license key for your Android app on developer.deepar.ai.

  1. Create an account: https://developer.deepar.ai/signup.
  2. Create a project: https://developer.deepar.ai/projects.
  3. Add a Android app to the project. Note that you need to specify the applicationId of your app.

Switch effects

AR filters are represented by effect files in DeepAR. You can load them to preview the effect.

Places you can get DeepAR effects:

Call switchEffect method to load an AR filter from a file.

License

Please see: https://developer.deepar.ai/customer-agreement

Permissions

SDK itself doesn't check for Android permissions but certain ones are required for the library to work correctly. Following are the required permissions:

  • Camera - Manifest.permission.CAMERA
  • External file storage - Manifest.permission.WRITE_EXTERNAL_STORAGE
  • Autofocus - android.hardware.camera.autofocus
  • Record audio - android.permission.RECORD_AUDIO

It is the responsibility of user provide required permissions.

Android 12+

Android 12 changes the policy of access to native vendor libraries. You can read about it here (see ENFORCE_NATIVE_SHARED_LIBRARY_DEPENDENCIES).

To ensure all DeepAR features work as expected (especially Background Segmentation), add the following code to your app’s manifest, inside the application tag.

AndroidManifest.xml
<uses-native-library
android:name="libOpenCL.so"
android:required="false" />

For Pixel devices, you may also need to add this code:

AndroidManifest.xml
<uses-native-library
android:name="libOpenCL-pixel.so"
android:required="false" />