Minimal reproduction for build failure in camera_android_camerax when using Gradle 9.x.
Related: flutter/packages#10906
| 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 |
git clone https://github.com/justshowcode/flutter_packages_camerax_repro
cd flutter_packages_camerax_repro
flutter pub get
cd android && ./gradlew assembleDebugNo code changes needed — just clone and run.
Running ./gradlew assembleDebug with the stock camera_android_camerax:0.6.30:
> Task :camera_android_camerax:compileDebugJavaWithJavac FAILED
/root/.gradle/caches/9.3.0/transforms/.../camera-core-1.5.3-api.jar
(/androidx/camera/core/SurfaceRequest.class):
error: Cannot attach type annotations @org.jspecify.annotations.NonNull
to SurfaceRequest.mSurfaceRecreationCompleter:
class file for androidx.concurrent.futures.CallbackToFutureAdapter not found
FAILURE: Build failed with an exception.
BUILD FAILED in 1m 5s
Add the missing dependency to 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")
// ...
}BUILD SUCCESSFUL in 44s
111 actionable tasks: 60 executed, 51 up-to-date
The Maven POM for camera-core:1.5.3 declares 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.
- Gradle 8.x — promotes transitive
runtimedependencies onto the compile classpath, so the build passes - Gradle 9.x — enforces strict classpath isolation, no longer does this promotion, so
CallbackToFutureAdapteris invisible to the compiler
The explicit implementation declaration fixes this by ensuring Gradle 9.x places
concurrent-futures on the compile classpath. It does not introduce any new dependency —
it was already pulled in transitively by camera-core.