Skip to content

fix(camera_android_camerax): Add missing androidx.concurrent:concurrent-futures dependency#11203

Open
0xfe10 wants to merge 2 commits intoflutter:mainfrom
repotea-open:fix/camera-android-camerax-concurrent-futures
Open

fix(camera_android_camerax): Add missing androidx.concurrent:concurrent-futures dependency#11203
0xfe10 wants to merge 2 commits intoflutter:mainfrom
repotea-open:fix/camera-android-camerax-concurrent-futures

Conversation

@0xfe10
Copy link

@0xfe10 0xfe10 commented Mar 9, 2026

Description

Fixes build failure when compiling with CameraX 1.5.2:
error: Cannot attach type annotations @org.jspecify.annotations.NonNull
class file for androidx.concurrent.futures.CallbackToFutureAdapter not found

The androidx.camera:camera-core:1.5.2 library internally uses CallbackToFutureAdapter from androidx.concurrent.futures, but this dependency was not explicitly declared in build.gradle.

This fix adds the missing androidx.concurrent:concurrent-futures:1.2.0 dependency to resolve the compilation error.

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue.

Root Cause

When camera plugin upgraded to use camera_android_camerax as the default Android implementation (in camera 0.11.0), projects using CameraX 1.5.2+ started experiencing compilation failures because the transitive dependency on androidx.concurrent.futures was not explicitly declared.

Changes

  • Added implementation("androidx.concurrent:concurrent-futures:1.2.0") to android/build.gradle dependencies

Testing

  • Verified build succeeds with AGP 8.9.1, Gradle 9.3.0, and compileSdk 35
  • Confirmed no runtime issues with camera functionality

Related Issue

This PR fixes build failures reported by users upgrading to camera 0.11.0+

Pre-Review Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter.
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets: [camera_android_camerax]
  • I linked to at least one issue that this PR fixes in the description above. (No existing issue found - this is a build configuration fix)
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy. (Version bump not required - build dependency fix only)
  • I updated CHANGELOG.md to add a description of the change. (CHANGELOG update not required - internal build dependency fix)
  • I updated/added any relevant documentation (doc comments with ///). (No API changes - documentation not required)
  • I added new tests to check the change I am making. (Test exemption - build dependency fix, no behavioral changes)
  • All existing and new tests are passing.

Exemption Justification: This PR only adds a missing build dependency declaration that should have been present. It does not change any API, behavior, or user-facing functionality. The dependency was already being used transitively but not explicitly declared, causing build failures in certain configurations.

continue for #10906

…nt-futures dependency

Fixes build failure when compiling with CameraX 1.5.2:
  error: Cannot attach type annotations @org.jspecify.annotations.NonNull
  class file for androidx.concurrent.futures.CallbackToFutureAdapter not found

The androidx.camera:camera-core:1.5.2 library internally uses
CallbackToFutureAdapter from androidx.concurrent.futures, but this
dependency was not explicitly declared in build.gradle.

This fix adds the missing androidx.concurrent:concurrent-futures:1.2.0
dependency to resolve the compilation error.
@0xfe10
Copy link
Author

0xfe10 commented Mar 9, 2026

continue for #10906

camera_android_camerax: build failure due to missing concurrent-futures dependency

Description

After upgrading my project to Flutter 3.38.7 with AGP 8.9.1 and Gradle 9.3.0,
the Android build started failing as soon as I added the camera plugin.

I tracked it down to a missing explicit dependency declaration for concurrent-futures
in camera_android_camerax's build.gradle. Adding that one line brought the build back.

I'm submitting this PR hoping upstream can include the same declaration.
I understand your example app runs fine — below is a full reproduction and root cause
analysis explaining why this failure is inevitable on Gradle 9.x.


Error

Running ./gradlew assembleDebug produces:

error: cannot access CallbackToFutureAdapter
  class file for androidx.concurrent.futures.CallbackToFutureAdapter not found

or

error: Cannot attach type annotations @org.jspecify.annotations.NonNull
  class file for androidx.concurrent.futures.CallbackToFutureAdapter not found

Reproduction

I've prepared a minimal reproduction project that demonstrates the issue out of the box:

Repo: https://github.com/justshowcode/flutter_packages_camerax_repro

git clone https://github.com/justshowcode/flutter_packages_camerax_repro
cd flutter_packages_camerax_repro
flutter pub get
cd android && ./gradlew assembleDebug

Environment:

Version
Flutter 3.41.4 (stable)
camera 0.11.3
camera_android_camerax 0.6.30 (camera-core:1.5.3)
AGP 8.9.1
Gradle 9.3.0
compileSdk 35
Java 17

No code changes needed — just clone and run to reproduce.


Root Cause

I checked the Maven POM for camera-core. Both 1.5.2 and the latest 1.5.3 declare
concurrent-futures as runtime scope:

<!-- https://dl.google.com/dl/android/maven2/androidx/camera/camera-core/1.5.3/camera-core-1.5.3.pom -->
<dependency>
  <groupId>androidx.concurrent</groupId>
  <artifactId>concurrent-futures</artifactId>
  <version>1.1.0</version>
  <scope>runtime</scope>
</dependency>

runtime scope means the dependency is not on the compile classpath — it's only
available at runtime.

  • Gradle 8.x — promotes transitive runtime dependencies onto the compile classpath,
    so the build passes
  • Gradle 9.x — enforces strict classpath isolation and no longer does this promotion,
    so CallbackToFutureAdapter is invisible to the compiler

This is why your example works — it's still on Gradle 8.x.
The POM declaration itself is arguably wrong: concurrent-futures is used at compile time
and should be compile scope, not runtime.


Fix

Explicitly declare the dependency in camera_android_camerax/android/build.gradle:

dependencies {
    def camerax_version = "1.5.3"
    implementation("androidx.camera:camera-core:${camerax_version}")
+   implementation("androidx.concurrent:concurrent-futures:1.2.0")
    // ...
}

This does not introduce any new dependency — concurrent-futures is already pulled in
transitively by camera-core. The explicit declaration simply ensures Gradle 9.x places
it on the compile classpath.

@0xfe10 0xfe10 marked this pull request as ready for review March 9, 2026 02:38
@0xfe10 0xfe10 requested a review from camsim99 as a code owner March 9, 2026 02:38
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the androidx.concurrent:concurrent-futures:1.2.0 dependency to the camera_android_camerax package's build.gradle file. This change is intended to resolve a build failure. My review includes one suggestion to define the new dependency's version in a variable to improve code consistency and maintainability.

Comment on lines 75 to +77
def camerax_version = "1.5.3"
implementation("androidx.camera:camera-core:${camerax_version}")
implementation("androidx.concurrent:concurrent-futures:1.2.0")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability and consistency, it's good practice to extract dependency versions into variables and group them at the top of the dependencies block.

    def camerax_version = "1.5.3"
    def concurrentFuturesVersion = "1.2.0"
    implementation("androidx.camera:camera-core:${camerax_version}")
    implementation("androidx.concurrent:concurrent-futures:${concurrentFuturesVersion}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant