CameraX is an addition to Android Jetpack that makes it easier to add camera capabilities to your app. The library provides a number of compatibility fixes and workarounds to help make the developer experience consistent across many devices.

For information on how to use the CameraX library in your app or library, see CameraX Overview.

Declaring dependencies

To add a dependency on CameraX, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the following to each module’s build.gradle file:

dependencies {
  // CameraX core library
  def camerax_version = "1.0.0-alpha05"
  // CameraX view library
  def camerax_view_version = "1.0.0-alpha02"
  // CameraX extensions library
  def camerax_ext_version = "1.0.0-alpha02"
  implementation "$camerax_version"
  // If you want to use Camera2 extensions
  implementation "$camerax_version"
  // If you to use the Camera View class
  implementation "$camerax_view_version"
  // If you to use Camera Extensions
  implementation "$camerax_ext_version"

CameraX Camera2 and Core Version 1.0.0-alpha05

September 5, 2019 and are released. These are the commits included in camera-camera2:1.0.0-alpha05 and these are the commits included camera-core:1.0.0-alpha05.

  • API Change: Renamed use case error variables:

    • ImageCapture.UseCaseError is renamed ImageCapture.ImageCaptureError
    • VideoCapture.UseCaseError is renamed VideoCapture.VideoCaptureError
  • Added CameraControl API w/Tap-to-Focus APIs

    • Added API to get a CameraControl from CameraX for a camera, selected by lens facing:

      CameraX.getCameraControl(LensFacing lensFacing)

    • Added MeteringPointFactory, MeteringPoint, MeteringMode, and FocusMeteringAction to run Tap-to-Focus:

      MeteringPointFactory factory = new SensorOrientedMeteringPointFactory(width, height);
      MeteringPoint point = factory.createPoint(x, y);
      FocusMeteringAction action = FocusMeteringAction.Builder.from(point,
          .addPoint(point2, MeteringMode.AE_ONLY) // could have many
          .setAutoFocusCallback(new OnAutoFocusListener(){
              public void onFocusCompleted(boolean isSuccess) {
          // auto calling cancelFocusAndMetering in 5 sec.
          .setAutoCancelDuration(5, TimeUnit.Second)
    • Added API for CameraControl to start and cancel focus metering:

      getCameraControl(lensFacing).startFocusAndMetering(action); getCameraControl(lensFacing).cancelFocusAndMetering();

    • Added APIs for Metering Point Factories that assist translating tap coordinates to sensor coordinates, based on view classes:

      MeteringPointFactory factory = new TextureViewMeteringPointFactory(textureView); MeteringPointFactory factory = new DisplayOrientedMeteringPointFactory(context, lensFacing, viewWidth, viewHeight);

  • Enforce calling the following methods on the Main (UI) thread, throwing an IllegalStateException when they are not. Future versions will allow usage on other threads and ensure serialization.

    • CameraX.bindToLifecycle()
    • CameraX.unbind()
    • CameraX.unbindAll()
    • ImageAnalysis.setAnalyzer()
    • ImageAnalysis.getAnalyzer()
    • ImageAnalysis.removeAnalyzer()
    • Preview.removePreviewOutputListener()
    • Preview.getOnPreviewOutputUpdateListener()
    • Preview.setOnPreviewOutputUpdateListener()
  • Various config settings now accept null parameters and corresponding getters may return null.

  • Fixed issue when testing on emulators that do not support AF/AE/AWB settings.

  • Fixed crash bug on rotation while analyzing image.

  • Fixed bug where preview appears black on start (no camera data), after rotation or switching between front and back cameras.

  • Removed testing for multiple concurrent image analysis use cases. To ensure compatibility, applications should only attach a single image analysis use case.

  • Added initial robolectric tests for fake camera in camera-testing suite (WIP).

  • Camera2Inititalizer test removed, as its coverage was unclear/misleading.

CameraX Extensions and View Version 1.0.0-alpha02

September 5, 2019 and are released. These are the commits included in camera-extensions:1.0.0-alpha02 and these are the commits included camera-view:1.0.0-alpha02.

  • Added tests to verify PreviewImageProcessorImpl has correctly implemented timestamps.
  • Fix ExtensionTest test failure on Nexus 5 (API level 21) and ensure preview is available.

CameraX Camera 2 / Core Version 1.0.0-alpha04

August 7, 2019 and are released. The commits included in this version can be found here.

New Features

Changes to Aspect Ratio and Resolution selection

CameraX's goal is to successfully initialize a camera session. This means CameraX will compromise on resolution/aspect ratios based on device capability, in order to start a capture session as its first goal, and so exact requests may not be honored. This may be due to:

  • Devices not supporting the requested resolution
  • Compatibility issues such as on LEGACY devices where certain resolutions must be used to operate correctly
  • On some devices, certain formats are only available at certain aspect ratios
  • A preference for a “nearest mod16” for JPEG or video encoding. See CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP

Although CameraX creates and manages the session, you should always check the returned image sizes on the use case output in your code and adjust accordingly.

Some changes have been made for setting resolutions and aspect ratios, intended to make the API more clear:

  • Preview use case is now considered to have a default 4:3 aspect ratio when none is set.
  • When CameraX internally considers changes to requested resolutions and aspect ratios based on device capability, it will first try to maintain the same aspect ratio (as determined by any of setTargetAspectRatio or setTargetResolution calls)
  • A “Nearest mod16” version of the resolution is considered as the same aspect ratio.

ImageAnalysis Non-Blocking Mode

  • The behaviour of ImageReaderMode.ACQUIRE_LATEST_IMAGE is now non-blocking. It acquires the latest image in the queue, but discards unused images continuously to allow the camera pipeline to avoid blocking.
  • The analyzer can hold a single image indefinitely without stalling the pipeline.
  • If the application provides an executor which then blocks, the ImageAnalysis use case will block.
  • The default executor set internally behaves as a non-blocking executor.

Bug Fixes

  • Fixed timeout issues waiting for 3A convergence when capturing images on devices with no auto-focus, auto exposure, and auto-whitebalance
  • Fixed issue when rapidly taking pictures with ImageCapture. Fixes error: java.lang.IllegalStateException: maxImages (2) has already been acquired
  • Fixed issue when setLensFacing was not called for a use case, resulting in java.lang.IllegalArgumentException: Unable to get camera ID for use case.
  • Fixed issue where LEGACY device required specific aspect ratio as maximum JPEG resolution
  • Fixed issue when backgrounding the app while camera is opening
  • Fixed issue on API < 25, removing error checkAndUpdateEglState: invalid current EGLDisplay
  • Fixed issue when unbinding preview after enabling and starting extensions
  • Build artifacts for camera-view and camera-extensions are now published as alpha versions

CameraX Extensions Version 1.0.0-alpha01

August 7, 2019 is released. The commits included in this version can be found here.

  • New library for future Camera Extensions for accessing effects on supported devices. This library is a work in progress.

CameraX View Version 1.0.0-alpha01

August 7, 2019 is released. The commits included in this version can be found here.

  • New Camera View class. This library is a work in progress.

Version 1.0.0-alpha03

July 2, 2019 and are released. The commits included in this version can be found here.

API Changes

  • Added javadoc clarification for “target” in setTarget configuration calls


  • Fixed unconfigured Input/Output Surface crash on rapid open/close or bind/unbind
  • Move to new Futures implementations
  • Test fixes for more robust testing
  • Core integration test now shows capture time for photos
  • Developed internal compat class for Executors
  • Timing test app capture images waits for previous to complete & improved stability


  • Added versioning checks
  • Additional test coverage - extension event callbacks
  • Improvements for internally corresponding image and meta-data
  • Fixes to mode switching in test app

Version 1.0.0-alpha02

June 5, 2019 and are released. The commits included in this version can be found here.

Bug fixes

  • Fixed div by zero issue when using emulator
  • Fixed NullPointerException/Surface Abandoned error occurring on some devices when quickly taking photos while unbinding and rebinding use cases rapidly.
  • Fixed internal issue to ensure capture request updates affect all surfaces consistently
  • Stability improvements when restarting use cases in new app instances
  • Internal architecture changes to prepare for supporting executors in the API
  • Additional Javadoc clarifications on CameraX class and lifecycle management
  • Added instrumented testing for Antelope performance test app
  • Remove need for '-keepattributes Signature' in app Proguard config

Version 1.0.0-alpha01

May 7, 2019 and are released. The commits included in this version are available here.