diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index 4e51b4e3b2e..e809b13d6e6 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.8+11 + +* Downgrades AGP version for compatibility with legacy projects. + ## 0.10.8+10 * Sets android.defaults.buildfeatures.buildconfig to true for compatibility with AGP 8.0+. diff --git a/packages/camera/camera_android/android/build.gradle b/packages/camera/camera_android/android/build.gradle index 3ddfc8cd5ce..faddec9d54f 100644 --- a/packages/camera/camera_android/android/build.gradle +++ b/packages/camera/camera_android/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.1.1' + classpath 'com.android.tools.build:gradle:7.3.0' } } diff --git a/packages/camera/camera_android/pubspec.yaml b/packages/camera/camera_android/pubspec.yaml index 28328d24343..f2c68922f17 100644 --- a/packages/camera/camera_android/pubspec.yaml +++ b/packages/camera/camera_android/pubspec.yaml @@ -3,7 +3,7 @@ description: Android implementation of the camera plugin. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.8+10 +version: 0.10.8+11 environment: sdk: ">=2.19.0 <4.0.0" diff --git a/script/configs/exclude_all_packages_app.yaml b/script/configs/exclude_all_packages_app.yaml index 60e7c7486fc..040087f10f5 100644 --- a/script/configs/exclude_all_packages_app.yaml +++ b/script/configs/exclude_all_packages_app.yaml @@ -6,15 +6,8 @@ # updating multiple packages for a breaking change in a common dependency in # cases where using a relaxed version constraint isn't possible. -# An application cannot depend directly on multiple federated implementations -# of the same plugin for the same platform, which means the app cannot -# directly depend on both camera_android and camera_android_androidx. -# Since camera_android is endorsed, it will be included transitively -# already, so exclude it from the direct dependency list to allow including -# camera_android_androidx to ensure that they don't conflict at build time -# (if they did, it would be impossible to use camera_android_androidx while -# camera_android is endorsed). -- camera_android +# NOTE: camera_android is semi-excluded via special casing in the repo tools. +# See create_all_packages_app_command.dart. # This is a permament entry, as it should never be a direct app dependency. - plugin_platform_interface diff --git a/script/tool/lib/src/create_all_packages_app_command.dart b/script/tool/lib/src/create_all_packages_app_command.dart index 061bc9915a7..ab49174a7b0 100644 --- a/script/tool/lib/src/create_all_packages_app_command.dart +++ b/script/tool/lib/src/create_all_packages_app_command.dart @@ -293,6 +293,20 @@ dependencies {} }, dependencyOverrides: pluginDeps, ); + + // An application cannot depend directly on multiple federated + // implementations of the same plugin for the same platform, which means the + // app cannot directly depend on both camera_android and + // camera_android_androidx. Since camera_android is endorsed, it will be + // included transitively already, so exclude it from the direct dependency + // list to allow including camera_android_androidx to ensure that they don't + // conflict at build time (if they did, it would be impossible to use + // camera_android_androidx while camera_android is endorsed). + // This is special-cased here, rather than being done via the normal + // exclusion config file mechanism, because it still needs to be in the + // depenedency overrides list to ensure that the version from path is used. + pubspec.dependencies.remove('camera_android'); + app.pubspecFile.writeAsStringSync(_pubspecToString(pubspec)); } diff --git a/script/tool/test/create_all_packages_app_command_test.dart b/script/tool/test/create_all_packages_app_command_test.dart index 6f7ba8ead2e..15d828a9099 100644 --- a/script/tool/test/create_all_packages_app_command_test.dart +++ b/script/tool/test/create_all_packages_app_command_test.dart @@ -10,6 +10,7 @@ import 'package:file/memory.dart'; import 'package:flutter_plugin_tools/src/common/core.dart'; import 'package:flutter_plugin_tools/src/create_all_packages_app_command.dart'; import 'package:platform/platform.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:test/test.dart'; import 'mocks.dart'; @@ -205,6 +206,38 @@ project 'Runner', { ])); }); + test( + 'pubspec special-cases camera_android to remove it from deps but not overrides', + () async { + writeFakeFlutterCreateOutput(testRoot); + final Directory cameraDir = packagesDir.childDirectory('camera'); + createFakePlugin('camera', cameraDir); + createFakePlugin('camera_android', cameraDir); + createFakePlugin('camera_android_camerax', cameraDir); + + await runCapturingPrint(runner, ['create-all-packages-app']); + final Pubspec pubspec = command.app.parsePubspec(); + + final Dependency? cameraDependency = pubspec.dependencies['camera']; + final Dependency? cameraAndroidDependency = + pubspec.dependencies['camera_android']; + final Dependency? cameraCameraXDependency = + pubspec.dependencies['camera_android_camerax']; + expect(cameraDependency, isA()); + expect((cameraDependency! as PathDependency).path, + endsWith('/packages/camera/camera')); + expect(cameraCameraXDependency, isA()); + expect((cameraCameraXDependency! as PathDependency).path, + endsWith('/packages/camera/camera_android_camerax')); + expect(cameraAndroidDependency, null); + + final Dependency? cameraAndroidOverride = + pubspec.dependencyOverrides['camera_android']; + expect(cameraAndroidOverride, isA()); + expect((cameraAndroidOverride! as PathDependency).path, + endsWith('/packages/camera/camera_android')); + }); + test('legacy files are copied when requested', () async { writeFakeFlutterCreateOutput(testRoot); createFakePlugin('plugina', packagesDir);