CameraX overview   Part of Android Jetpack.

CameraX is a Jetpack support library, built to help you make camera app development easier. It provides a consistent and easy-to-use API surface that works across most Android devices, with backward-compatibility to Android 5.0 (API level 21).

While CameraX leverages the capabilities of camera2, it uses a simpler approach that is lifecycle-aware and is based on use cases. It also resolves device compatibility issues for you so that you don't have to include device-specific code in your code base. These features reduce the amount of code you need to write when adding camera capabilities to your app.

Lastly, CameraX enables developers to leverage the same camera experiences and features that preinstalled camera apps provide, with as little as two lines of code. CameraX Extensions are optional add-ons that enable you to add effects on supported devices. These effects include Bokeh(Portrait), HDR, Night, and Face Retouch.

Primary benefits

CameraX improves the developer experience in the following ways:

Broad device coverage

CameraX is designed to support devices running Android 5.0 (API level 21) and higher, representing over 94% of existing Android devices.

Ease of use

CameraX introduces use cases, which allow you to focus on the task you need to get done instead of spending time managing device-specific nuances. Most commmon camera use cases are supported with more features being constantly added:

Again, these use cases work across all devices running Android 5.0 (API level 21) or higher, ensuring that the same code works on most devices in the market.

Consistency across devices

Figure 2. Automated CameraX test lab ensures a consistent API experience across many device types and manufacturers.

Managing consistent camera behavior across apps is hard. There is a lot to account for, including aspect ratio, orientation, rotation, preview size, and high-resolution image size. With CameraX, these basic behaviors just work.

We’re investing in an automated CameraX test lab that tests a variety of camera behaviors across a range of devices and all operating system flavors since Android 5.0 (API level 21). These tests are run on an ongoing basis to identify and fix a wide range of issues.

Our aim is to, over time, significantly reduce your test burden.

New camera experiences

Figure 3. An image captured with the Bokeh (Portrait) effect using CameraX.

CameraX has an optional add-on, called Extensions, which allow you to access the same features and capabilities as those in the native camera app that ships with the device, with just two lines of code.

The supported extensions include Bokeh (Portrait), HDR, Night, and Face Retouch. These capabilities are available only on supported devices.

Case study

To see how CameraX has simplified development for Monzo, see their case study.

Additional resources

To learn more about CameraX, consult the following additional resources.

Codelab

  • Getting Started with CameraX
  • Code sample

  • Official CameraX sample app