Skip to content

[camera_android] Downgrade to AGP 7.3.0 to fix build_alll_packages test failures #4997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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+.
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.android.tools.build:gradle:7.3.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 2 additions & 9 deletions script/configs/exclude_all_packages_app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions script/tool/lib/src/create_all_packages_app_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
33 changes: 33 additions & 0 deletions script/tool/test/create_all_packages_app_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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, <String>['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<PathDependency>());
expect((cameraDependency! as PathDependency).path,
endsWith('/packages/camera/camera'));
expect(cameraCameraXDependency, isA<PathDependency>());
expect((cameraCameraXDependency! as PathDependency).path,
endsWith('/packages/camera/camera_android_camerax'));
expect(cameraAndroidDependency, null);

final Dependency? cameraAndroidOverride =
pubspec.dependencyOverrides['camera_android'];
expect(cameraAndroidOverride, isA<PathDependency>());
expect((cameraAndroidOverride! as PathDependency).path,
endsWith('/packages/camera/camera_android'));
});

test('legacy files are copied when requested', () async {
writeFakeFlutterCreateOutput(testRoot);
createFakePlugin('plugina', packagesDir);
Expand Down