camera viewfinder
This table lists all the artifacts in the androidx.camera-viewfinder
group.
Artifact | Stable Release | Release Candidate | Beta Release | Alpha Release |
---|---|---|---|---|
viewfinder-compose | - | - | 1.5.0-beta03 | 1.4.0-alpha13 |
viewfinder-core | - | - | 1.5.0-beta03 | 1.4.0-alpha13 |
viewfinder-view | - | - | 1.5.0-beta03 | 1.4.0-alpha13 |
Declaring dependencies
To add a dependency on camera-viewfinder, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle
file for
your app or module:
Groovy
dependencies { // Use to implement camera viewfinders implementation "androidx.camera.viewfinder:viewfinder-view:1.5.0-beta03" implementation "androidx.camera.viewfinder:viewfinder-compose:1.5.0-beta03" implementation "androidx.camera.viewfinder:viewfinder-core:1.5.0-beta03" }
Kotlin
dependencies { // Use to implement camera viewfinders implementation("androidx.camera.viewfinder:viewfinder-view:1.5.0-beta03") implementation("androidx.camera.viewfinder:viewfinder-core:1.5.0-beta03") implementation("androidx.camera.viewfinder:viewfinder-compose:1.5.0-beta03") }
For more information about dependencies, see Add build dependencies.
Feedback
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Version 1.5
Version 1.5.0-beta03
July 16, 2025
androidx.camera.viewfinder:viewfinder-compose:1.5.0-beta03
, androidx.camera.viewfinder:viewfinder-core:1.5.0-beta03
, and androidx.camera.viewfinder:viewfinder-view:1.5.0-beta03
are released. Version 1.5.0-beta03 contains these commits.
Bug Fixes
- The default
ImplementationMode
forViewfinder
(both Compose and View-based) now intelligently selects betweenEXTERNAL
(for performance) andEMBEDDED
(for compatibility on older APIs/quirky devices). This behavior can still be overridden by explicit settings inViewfinderSurfaceRequest
or XML attributes (on the View-based API). (Iecd3a) - Improved Surface session management by allowing the
ViewfinderSurfaceSession
to be kept alive across surface create/destroy lifecycles when using TextureView or SurfaceView on API 29+. (I112d9) - The
Viewfinder
now ensures Surfaces are released at the proper time, only when no longer in use by the session, rather than always releasing when the Composable is disposed. ForEXTERNAL
(SurfaceView
) this behavior is currently only available on API 29+. ForEMBEDDED
(TextureView
), this behavior is present on all API levels. (I9a03f) - The
Viewfinder
now properly handles surface replacement in scenarios such as when anEXTERNAL
viewfinder on API level 28 or lower moves off screen or if aViewfinder
(with anyImplementationMode
) is part ofmoveableContentOf()
. (I79432) - Composable
Viewfinder
now works correctly with Compose'sPager
. This change ensures that the Composable can be successfully reset by implementing theonReset
callback ofAndroidView
, supporting bothEMBEDDED
andEXTERNAL
implementations. (I0d9be) - Fixes an issue on Android 10/11 where the
EXTERNAL
Viewfinder
could appear stretched or incorrect due to transformation operations (like scale or translate) being applied too early. The system now waits for the Surface to be created before applying these transformations in the layout phase, ensuring correct output. (Icc77c)
Version 1.5.0-beta02
June 4, 2025
androidx.camera.viewfinder:viewfinder-compose:1.5.0-beta02
, androidx.camera.viewfinder:viewfinder-core:1.5.0-beta02
, and androidx.camera.viewfinder:viewfinder-view:1.5.0-beta02
are released. Version 1.5.0-beta02 contains these commits.
Version 1.5.0-beta01
May 7, 2025
androidx.camera.viewfinder:viewfinder-compose:1.5.0-beta01
, androidx.camera.viewfinder:viewfinder-core:1.5.0-beta01
, and androidx.camera.viewfinder:viewfinder-view:1.5.0-beta01
are released. Version 1.5.0-beta01 contains these commits.
- This is the first official beta release of the view-based and compose-based viewfinders that are flexible enough to be used with Camera2. If you’re looking for a View or composable to use with CameraX, see
PreviewView
andCameraXViewfinder
.
New Features
ContentScale
andAlignment
can now be used in the compose-based viewfinder to scale and place the displayed surface within its container, similar to howandroidx.compose.foundation.Image
behaves. (Ibcea3)
API Changes
TransformationInfo
now has default values for all args. This will allow Viewfinders to be created without anyTransformationInfo
, which will default to a source rotation of 0, no source mirroring, and no crop rect. (I2b1b2)- Composable Viewfinder now takes a trailing lambda to receive a Surface session, similar to
AndroidExternalSurface
. The provided lambda usesViewfinderInitScope
as a receiver, which allows installing a callback to receive new Surface sessions. These surface sessions automatically release resources held by the Viewfinder when they go out of scope. (Ib2b0d) ViewfinderSurfaceRequest.Builder.populateFromCharacteristics
has now been removed and is now replaced with an equivalent set of static APIs that can be used to generateTransformationInfo
which will produce the same transformation aspopulateFromCharacteristics
. These static methods are added to theCamera2TransformationInfo
class. (Idc6af)ViewfinderSurfaceRequest
no longer includes async APIs for retrieving the surface. It is now an immutable data type. APIs for retrieving the Surface are now moved to the viewfinder. (I30127)CameraViewfinder
has been renamed toViewfinderView
so that the naming aligns with the naming of the Viewfinder composable and to indicate that it can be used with more than just camera sources. (Id9e6b)- Classes from
viewfinder-view
have been moved to theandroidx.camera.viewfinder.view
subpackage from theandroidx.camera.viewfinder
package. (I6cb44) - New APIs are added to view-based Viewfinder that allow setting the source rotation, mirroring, and crop rectangle. This
TransformationInfo
class is the same class used by the compose-based Viewfinder. (I907c3) - The view-based Viewfinder now uses new
ViewfinderSurfaceRequest
APIs which no longer internally handle the Surface response. Instead of returningListenableFuture<Surface>
, therequestSurfaceSession()
APIs now returnListenableFuture<ViewfinderSurfaceSession>
which returns anAutoCloseable
class that when closed behaves the same way as calling the old API ofViewfinderSurfaceRequest.markSurfaceSafeToRelease()
. This provides a clearer separation of responsibilities between the surface request and surface response. (I19041)
Version 1.4
Version 1.4.0-alpha13
February 26, 2025
androidx.camera.viewfinder:viewfinder-compose:1.4.0-alpha13
, androidx.camera.viewfinder:viewfinder-core:1.4.0-alpha13
, and androidx.camera.viewfinder:viewfinder-view:1.4.0-alpha13
are released. Version 1.4.0-alpha13 contains these commits.
Version 1.4.0-alpha12
January 15, 2025
androidx.camera.viewfinder:viewfinder-compose:1.4.0-alpha12
, androidx.camera.viewfinder:viewfinder-core:1.4.0-alpha12
, and androidx.camera.viewfinder:viewfinder-view:1.4.0-alpha12
are released. Version 1.4.0-alpha12 contains these commits.
New Features
- Upgraded
compileSdk
as 35 for using Android 15 related API. Apps using CameraX libraries will also need to upgrade theircompileSdk
config setting. (Ic80cd) - This library now uses JSpecify nullness annotations, which are type-use. Kotlin developers should use the following compiler argument to enforce correct usage:
-Xjspecify-annotations=strict
(this is the default starting with version 2.1.0 of the Kotlin compiler). (I7bcd7, b/326456246)
Version 1.4.0-alpha11
December 11, 2024
androidx.camera.viewfinder:viewfinder-compose:1.4.0-alpha11
, androidx.camera.viewfinder:viewfinder-core:1.4.0-alpha11
, and androidx.camera.viewfinder:viewfinder-view:1.4.0-alpha11
are released. Version 1.4.0-alpha11 contains these commits.
API Changes
viewfinder-core
classes have been moved into packages that are consistent with the library they belong to. (I431c6)CameraViewfinder.ScaleType
has been moved toviewfinder-core
so it can be reused with compose (I87ef1)- Deprecated
CameraViewfinder
classes are removed. Please use the new APIs which provide equivalent functionality. (I6e59a)
Version 1.4.0-alpha10
October 30, 2024
androidx.camera.viewfinder:viewfinder-compose:1.4.0-alpha10
, androidx.camera.viewfinder:viewfinder-core:1.4.0-alpha10
, and androidx.camera.viewfinder:viewfinder-view:1.4.0-alpha10
are released. Version 1.4.0-alpha10 contains these commits.
Version 1.4.0-alpha09
October 2, 2024
androidx.camera.viewfinder:viewfinder-compose:1.4.0-alpha09
, androidx.camera.viewfinder:viewfinder-core:1.4.0-alpha09
, and androidx.camera.viewfinder:viewfinder-view:1.4.0-alpha09
are released. Version 1.4.0-alpha09 contains these commits.
Version 1.4.0-alpha08
September 4, 2024
androidx.camera.viewfinder:viewfinder-compose:1.4.0-alpha08
, androidx.camera.viewfinder:viewfinder-core:1.4.0-alpha08
, and androidx.camera.viewfinder:viewfinder-view:1.4.0-alpha08
are released. Version 1.4.0-alpha08 contains these commits.
New Features
With the update to 1.4.0-alpha08, the CameraX Viewfinder artifact has been moved to its own library group. This change is necessary to improve the modularity and maintainability of the CameraX library.
If you were previously depending on androidx.camera:camera-viewfinder
, androidx.camera:camera-viewfinder-compose
or androidx.camera:camera-viewfinder-core
, you will need to transition your dependencies to the following:
androidx.camera:camera-viewfinder
->androidx.camera.viewfinder:viewfinder-view
androidx.camera:camera-viewfinder-compose
->androidx.camera.viewfinder:viewfinder-compose
androidx.camera:camera-viewfinder-core
->androidx.camera.viewfinder:viewfinder-core
No code changes should be needed to make this transition. The old Viewfinder maven coordinates will no longer receive updates.
Additionally, if you are using Compose with CameraX, a new Compose-first library is now available in alpha: androidx.camera:camera-compose
. This provides the CameraXViewfinder
composable, which is a compose-idiomatic Viewfinder that adapts CameraX’s SurfaceRequest
to Compose, similar to how PreviewView
works for views.