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 it leverages the capabilities of camera2, it uses a simpler, use case-based approach that is lifecycle-aware. 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 Portrait, HDR, Night, and Beauty.
The core CameraX libraries are
in beta stage. Beta releases are functionally stable and have a feature-complete API surface. They
are ready for production use but may contain bugs.
For more information on the status of each library, see the CameraX library status page.
CameraX improves the developer experience in the following ways:
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. There are several basic use cases:
- Preview: get an image on the display
- Image analysis: access a buffer seamlessly for use in your algorithms, such as to pass into MLKit
- Image capture: save high-quality images
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
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
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 first set of capabilities available include Portrait, HDR, Night, and Beauty. These capabilities are available on supported devices.
To learn more about CameraX, consult the following additional resources.