fix(camera_android_camerax): Add missing androidx.concurrent:concurrent-futures dependency#11203
Conversation
…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.
|
continue for #10906 camera_android_camerax: build failure due to missing concurrent-futures dependencyDescriptionAfter upgrading my project to Flutter 3.38.7 with AGP I tracked it down to a missing explicit dependency declaration for I'm submitting this PR hoping upstream can include the same declaration. ErrorRunning or ReproductionI'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 assembleDebugEnvironment:
No code changes needed — just clone and run to reproduce. Root CauseI checked the Maven POM for <!-- 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>
This is why your example works — it's still on Gradle 8.x. FixExplicitly declare the dependency in 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 — |
There was a problem hiding this comment.
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.
| def camerax_version = "1.5.3" | ||
| implementation("androidx.camera:camera-core:${camerax_version}") | ||
| implementation("androidx.concurrent:concurrent-futures:1.2.0") |
There was a problem hiding this comment.
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}")
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_cameraxas the default Android implementation (in camera 0.11.0), projects using CameraX 1.5.2+ started experiencing compilation failures because the transitive dependency onandroidx.concurrent.futureswas not explicitly declared.Changes
implementation("androidx.concurrent:concurrent-futures:1.2.0")toandroid/build.gradledependenciesTesting
Related Issue
This PR fixes build failures reported by users upgrading to camera 0.11.0+
Pre-Review Checklist
[camera_android_camerax]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy. (Version bump not required - build dependency fix only)CHANGELOG.mdto add a description of the change. (CHANGELOG update not required - internal build dependency fix)///). (No API changes - documentation not required)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