Skip to content

Commit a9a8cc6

Browse files
authored
[camera_android] Downgrade to AGP 7.3.0 to fix build_alll_packages test failures (#4997)
Fixes the current failures of the build_all_packages tests that were caused in https://github.com/flutter/packages/pull/4951/files.
1 parent 619af75 commit a9a8cc6

File tree

6 files changed

+55
-11
lines changed

6 files changed

+55
-11
lines changed

packages/camera/camera_android/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.8+11
2+
3+
* Downgrades AGP version for compatibility with legacy projects.
4+
15
## 0.10.8+10
26

37
* Sets android.defaults.buildfeatures.buildconfig to true for compatibility with AGP 8.0+.

packages/camera/camera_android/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:8.1.1'
12+
classpath 'com.android.tools.build:gradle:7.3.0'
1313
}
1414
}
1515

packages/camera/camera_android/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.8+10
6+
version: 0.10.8+11
77

88
environment:
99
sdk: ">=2.19.0 <4.0.0"

script/configs/exclude_all_packages_app.yaml

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@
66
# updating multiple packages for a breaking change in a common dependency in
77
# cases where using a relaxed version constraint isn't possible.
88

9-
# An application cannot depend directly on multiple federated implementations
10-
# of the same plugin for the same platform, which means the app cannot
11-
# directly depend on both camera_android and camera_android_androidx.
12-
# Since camera_android is endorsed, it will be included transitively
13-
# already, so exclude it from the direct dependency list to allow including
14-
# camera_android_androidx to ensure that they don't conflict at build time
15-
# (if they did, it would be impossible to use camera_android_androidx while
16-
# camera_android is endorsed).
17-
- camera_android
9+
# NOTE: camera_android is semi-excluded via special casing in the repo tools.
10+
# See create_all_packages_app_command.dart.
1811

1912
# This is a permament entry, as it should never be a direct app dependency.
2013
- plugin_platform_interface

script/tool/lib/src/create_all_packages_app_command.dart

+14
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,20 @@ dependencies {}
293293
},
294294
dependencyOverrides: pluginDeps,
295295
);
296+
297+
// An application cannot depend directly on multiple federated
298+
// implementations of the same plugin for the same platform, which means the
299+
// app cannot directly depend on both camera_android and
300+
// camera_android_androidx. Since camera_android is endorsed, it will be
301+
// included transitively already, so exclude it from the direct dependency
302+
// list to allow including camera_android_androidx to ensure that they don't
303+
// conflict at build time (if they did, it would be impossible to use
304+
// camera_android_androidx while camera_android is endorsed).
305+
// This is special-cased here, rather than being done via the normal
306+
// exclusion config file mechanism, because it still needs to be in the
307+
// depenedency overrides list to ensure that the version from path is used.
308+
pubspec.dependencies.remove('camera_android');
309+
296310
app.pubspecFile.writeAsStringSync(_pubspecToString(pubspec));
297311
}
298312

script/tool/test/create_all_packages_app_command_test.dart

+33
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:file/memory.dart';
1010
import 'package:flutter_plugin_tools/src/common/core.dart';
1111
import 'package:flutter_plugin_tools/src/create_all_packages_app_command.dart';
1212
import 'package:platform/platform.dart';
13+
import 'package:pubspec_parse/pubspec_parse.dart';
1314
import 'package:test/test.dart';
1415

1516
import 'mocks.dart';
@@ -205,6 +206,38 @@ project 'Runner', {
205206
]));
206207
});
207208

209+
test(
210+
'pubspec special-cases camera_android to remove it from deps but not overrides',
211+
() async {
212+
writeFakeFlutterCreateOutput(testRoot);
213+
final Directory cameraDir = packagesDir.childDirectory('camera');
214+
createFakePlugin('camera', cameraDir);
215+
createFakePlugin('camera_android', cameraDir);
216+
createFakePlugin('camera_android_camerax', cameraDir);
217+
218+
await runCapturingPrint(runner, <String>['create-all-packages-app']);
219+
final Pubspec pubspec = command.app.parsePubspec();
220+
221+
final Dependency? cameraDependency = pubspec.dependencies['camera'];
222+
final Dependency? cameraAndroidDependency =
223+
pubspec.dependencies['camera_android'];
224+
final Dependency? cameraCameraXDependency =
225+
pubspec.dependencies['camera_android_camerax'];
226+
expect(cameraDependency, isA<PathDependency>());
227+
expect((cameraDependency! as PathDependency).path,
228+
endsWith('/packages/camera/camera'));
229+
expect(cameraCameraXDependency, isA<PathDependency>());
230+
expect((cameraCameraXDependency! as PathDependency).path,
231+
endsWith('/packages/camera/camera_android_camerax'));
232+
expect(cameraAndroidDependency, null);
233+
234+
final Dependency? cameraAndroidOverride =
235+
pubspec.dependencyOverrides['camera_android'];
236+
expect(cameraAndroidOverride, isA<PathDependency>());
237+
expect((cameraAndroidOverride! as PathDependency).path,
238+
endsWith('/packages/camera/camera_android'));
239+
});
240+
208241
test('legacy files are copied when requested', () async {
209242
writeFakeFlutterCreateOutput(testRoot);
210243
createFakePlugin('plugina', packagesDir);

0 commit comments

Comments
 (0)