Revert "Revert "Use AndroidX in new projects by default (#40925)" (#40995)" (#41001)
This reverts commit 8e231796272f7f14391ca9c6b40392bc20f96aeb.
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index 2e5ad13..4c35620 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -141,7 +141,7 @@
argParser.addFlag(
'androidx',
negatable: true,
- defaultsTo: false,
+ defaultsTo: true,
help: 'Generate a project using the AndroidX support libraries',
);
// Deprecated
@@ -398,7 +398,7 @@
final String relativeDirPath = fs.path.relative(projectDirPath);
if (!projectDir.existsSync() || projectDir.listSync().isEmpty) {
- printStatus('Creating project $relativeDirPath...');
+ printStatus('Creating project $relativeDirPath... androidx: ${argResults['androidx']}');
} else {
if (sampleCode != null && !argResults['overwrite']) {
throwToolExit('Will not overwrite existing project in $relativeDirPath: '
diff --git a/packages/flutter_tools/test/general.shard/commands/create_test.dart b/packages/flutter_tools/test/general.shard/commands/create_test.dart
index eb57323..1cb6650 100644
--- a/packages/flutter_tools/test/general.shard/commands/create_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/create_test.dart
@@ -417,7 +417,7 @@
}, timeout: allowForRemotePubInvocation);
- testUsingContext('androidx app project', () async {
+ testUsingContext('androidx is used by default in an app project', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
@@ -425,7 +425,7 @@
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
- await runner.run(<String>['create', '--no-pub', '--androidx', projectDir.path]);
+ await runner.run(<String>['create', '--no-pub', projectDir.path]);
void expectExists(String relPath) {
expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
@@ -459,7 +459,7 @@
expect(actualContents.contains('useAndroidX'), false);
}, timeout: allowForCreateFlutterProject);
- testUsingContext('androidx app module', () async {
+ testUsingContext('androidx is used by default in a module project', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
@@ -467,7 +467,7 @@
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
- await runner.run(<String>['create', '--template=module', '--no-pub', '--androidx', projectDir.path]);
+ await runner.run(<String>['create', '--template=module', '--no-pub', projectDir.path]);
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
expect(
@@ -476,7 +476,7 @@
);
}, timeout: allowForCreateFlutterProject);
- testUsingContext('non androidx app module', () async {
+ testUsingContext('non androidx module', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
@@ -493,7 +493,7 @@
);
}, timeout: allowForCreateFlutterProject);
- testUsingContext('androidx plugin project', () async {
+ testUsingContext('androidx is used by default in a plugin project', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
@@ -501,7 +501,7 @@
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
- await runner.run(<String>['create', '--no-pub', '--template=plugin', '--androidx', projectDir.path]);
+ await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]);
void expectExists(String relPath) {
expect(fs.isFileSync('${projectDir.path}/$relPath'), true);