Make --androidx flag a noop in flutter create (#52340)
diff --git a/dev/devicelab/bin/tasks/gradle_jetifier_test.dart b/dev/devicelab/bin/tasks/gradle_jetifier_test.dart
index 5c44fd4..08991f9 100644
--- a/dev/devicelab/bin/tasks/gradle_jetifier_test.dart
+++ b/dev/devicelab/bin/tasks/gradle_jetifier_test.dart
@@ -34,7 +34,6 @@
'create',
options: <String>[
'--org', 'io.flutter.devicelab',
- '--androidx',
'hello',
],
);
diff --git a/dev/devicelab/bin/tasks/gradle_plugin_dependencies_test.dart b/dev/devicelab/bin/tasks/gradle_plugin_dependencies_test.dart
index e0054a5..68d38bd 100644
--- a/dev/devicelab/bin/tasks/gradle_plugin_dependencies_test.dart
+++ b/dev/devicelab/bin/tasks/gradle_plugin_dependencies_test.dart
@@ -35,7 +35,6 @@
'create',
options: <String>[
'--org', 'io.flutter.devicelab',
- '--androidx',
'hello',
],
);
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index 6a97448..c5ad2c3 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -139,11 +139,12 @@
defaultsTo: 'kotlin',
allowed: <String>['java', 'kotlin'],
);
+ // TODO(egarciad): Remove this flag. https://github.com/flutter/flutter/issues/52363
argParser.addFlag(
'androidx',
+ hide: true,
negatable: true,
- defaultsTo: true,
- help: 'Generate a project using the AndroidX support libraries',
+ help: 'Deprecated. Setting this flag has no effect.',
);
}
@@ -401,7 +402,6 @@
flutterRoot: flutterRoot,
renderDriverTest: boolArg('with-driver-test'),
withPluginHook: generatePlugin,
- androidX: boolArg('androidx'),
androidLanguage: stringArg('android-language'),
iosLanguage: stringArg('ios-language'),
web: featureFlags.isWebEnabled,
@@ -411,7 +411,7 @@
final String relativeDirPath = globals.fs.path.relative(projectDirPath);
if (!projectDir.existsSync() || projectDir.listSync().isEmpty) {
- globals.printStatus('Creating project $relativeDirPath... androidx: ${boolArg('androidx')}');
+ globals.printStatus('Creating project $relativeDirPath...');
} else {
if (sampleCode != null && !overwrite) {
throwToolExit('Will not overwrite existing project in $relativeDirPath: '
@@ -619,7 +619,6 @@
String projectName,
String projectDescription,
String androidLanguage,
- bool androidX,
String iosLanguage,
String flutterRoot,
bool renderDriverTest = false,
@@ -644,7 +643,6 @@
'macosIdentifier': appleIdentifier,
'description': projectDescription,
'dartSdk': '$flutterRoot/bin/cache/dart-sdk',
- 'androidX': androidX,
'useAndroidEmbeddingV2': featureFlags.isAndroidEmbeddingV2Enabled,
'androidMinApiLevel': android.minApiLevel,
'androidSdkVersion': android_sdk.minimumAndroidSdkVersion,
diff --git a/packages/flutter_tools/lib/src/plugins.dart b/packages/flutter_tools/lib/src/plugins.dart
index a0dd1f5..3343a1f 100644
--- a/packages/flutter_tools/lib/src/plugins.dart
+++ b/packages/flutter_tools/lib/src/plugins.dart
@@ -527,14 +527,9 @@
const String _androidPluginRegistryTemplateNewEmbedding = '''
package io.flutter.plugins;
-{{#androidX}}
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
-{{/androidX}}
-{{^androidX}}
-import android.support.annotation.Keep;
-import android.support.annotation.NonNull;
-{{/androidX}}
+
import io.flutter.embedding.engine.FlutterEngine;
{{#needsShim}}
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;
diff --git a/packages/flutter_tools/templates/app/android.tmpl/gradle.properties.tmpl b/packages/flutter_tools/templates/app/android.tmpl/gradle.properties.tmpl
index 2a0d268..38c8d45 100644
--- a/packages/flutter_tools/templates/app/android.tmpl/gradle.properties.tmpl
+++ b/packages/flutter_tools/templates/app/android.tmpl/gradle.properties.tmpl
@@ -1,6 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
-{{#androidX}}
android.useAndroidX=true
android.enableJetifier=true
-{{/androidX}}
diff --git a/packages/flutter_tools/templates/module/android/gradle/gradle.properties.tmpl b/packages/flutter_tools/templates/module/android/gradle/gradle.properties.tmpl
index 2a0d268..38c8d45 100644
--- a/packages/flutter_tools/templates/module/android/gradle/gradle.properties.tmpl
+++ b/packages/flutter_tools/templates/module/android/gradle/gradle.properties.tmpl
@@ -1,6 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
-{{#androidX}}
android.useAndroidX=true
android.enableJetifier=true
-{{/androidX}}
diff --git a/packages/flutter_tools/templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl b/packages/flutter_tools/templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl
index 5c5f482..c52a08e 100644
--- a/packages/flutter_tools/templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl
+++ b/packages/flutter_tools/templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl
@@ -34,13 +34,6 @@
dependencies {
implementation project(':flutter')
implementation fileTree(dir: 'libs', include: ['*.jar'])
- {{#androidX}}
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- {{/androidX}}
- {{^androidX}}
- implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.2'
- implementation 'com.android.support:design:28.0.0'
- {{/androidX}}
}
diff --git a/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/build.gradle.tmpl b/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/build.gradle.tmpl
index b3defac..64c2690 100644
--- a/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/build.gradle.tmpl
+++ b/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/build.gradle.tmpl
@@ -45,11 +45,5 @@
}
dependencies {
- {{#androidX}}
implementation 'androidx.appcompat:appcompat:1.0.2'
- {{/androidX}}
- {{^androidX}}
- implementation 'com.android.support:support-v13:27.1.1'
- implementation 'com.android.support:support-annotations:27.1.1'
- {{/androidX}}
}
diff --git a/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/Flutter.java.tmpl b/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/Flutter.java.tmpl
index 4a3365e..6716ecf 100644
--- a/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/Flutter.java.tmpl
+++ b/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/Flutter.java.tmpl
@@ -4,18 +4,11 @@
import android.content.Context;
import android.os.Bundle;
-{{#androidX}}
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
-{{/androidX}}
-{{^androidX}}
-import android.arch.lifecycle.Lifecycle;
-import android.arch.lifecycle.LifecycleObserver;
-import android.arch.lifecycle.OnLifecycleEvent;
-import android.support.annotation.NonNull;
-{{/androidX}}
+
import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.StringCodec;
import io.flutter.plugins.GeneratedPluginRegistrant;
diff --git a/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/FlutterFragment.java.tmpl b/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/FlutterFragment.java.tmpl
index 636bf52..10565a5 100644
--- a/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/FlutterFragment.java.tmpl
+++ b/packages/flutter_tools/templates/module/android/library/Flutter.tmpl/src/main/java/io/flutter/facade/FlutterFragment.java.tmpl
@@ -6,14 +6,9 @@
import android.view.LayoutInflater;
import android.view.ViewGroup;
-{{#androidX}}
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
-{{/androidX}}
-{{^androidX}}
-import android.support.annotation.NonNull;
-import android.support.v4.app.Fragment;
-{{/androidX}}
+
import io.flutter.view.FlutterView;
/**
diff --git a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl
index f1874fc..f5b96a0 100644
--- a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl
+++ b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl
@@ -85,6 +85,6 @@
# They also do not have any bearing on your native host application's
# identifiers, which may be completely independent or the same as these.
module:
- androidX: {{androidX}}
+ androidX: true
androidPackage: {{androidIdentifier}}
iosBundleIdentifier: {{iosIdentifier}}
diff --git a/packages/flutter_tools/templates/plugin/android-java.tmpl/src/main/java/androidIdentifier/pluginClass.java.tmpl b/packages/flutter_tools/templates/plugin/android-java.tmpl/src/main/java/androidIdentifier/pluginClass.java.tmpl
index 6616555..c8cd205 100644
--- a/packages/flutter_tools/templates/plugin/android-java.tmpl/src/main/java/androidIdentifier/pluginClass.java.tmpl
+++ b/packages/flutter_tools/templates/plugin/android-java.tmpl/src/main/java/androidIdentifier/pluginClass.java.tmpl
@@ -1,12 +1,8 @@
package {{androidIdentifier}};
{{#useAndroidEmbeddingV2}}
-{{#androidX}}
import androidx.annotation.NonNull;
-{{/androidX}}
-{{^androidX}}
-import android.support.annotation.NonNull;
-{{/androidX}}
+
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
diff --git a/packages/flutter_tools/templates/plugin/android-kotlin.tmpl/src/main/kotlin/androidIdentifier/pluginClass.kt.tmpl b/packages/flutter_tools/templates/plugin/android-kotlin.tmpl/src/main/kotlin/androidIdentifier/pluginClass.kt.tmpl
index 6d1b58c..9d4b256 100644
--- a/packages/flutter_tools/templates/plugin/android-kotlin.tmpl/src/main/kotlin/androidIdentifier/pluginClass.kt.tmpl
+++ b/packages/flutter_tools/templates/plugin/android-kotlin.tmpl/src/main/kotlin/androidIdentifier/pluginClass.kt.tmpl
@@ -1,12 +1,8 @@
package {{androidIdentifier}}
{{#useAndroidEmbeddingV2}}
-{{#androidX}}
import androidx.annotation.NonNull;
-{{/androidX}}
-{{^androidX}}
-import android.support.annotation.NonNull;
-{{/androidX}}
+
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
diff --git a/packages/flutter_tools/templates/plugin/android.tmpl/gradle.properties.tmpl b/packages/flutter_tools/templates/plugin/android.tmpl/gradle.properties.tmpl
index 2a0d268..38c8d45 100644
--- a/packages/flutter_tools/templates/plugin/android.tmpl/gradle.properties.tmpl
+++ b/packages/flutter_tools/templates/plugin/android.tmpl/gradle.properties.tmpl
@@ -1,6 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
-{{#androidX}}
android.useAndroidX=true
android.enableJetifier=true
-{{/androidX}}
diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
index 62afce0..88a5760 100644
--- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
+++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
@@ -488,27 +488,6 @@
expect(actualContents.contains('useAndroidX'), true);
});
- testUsingContext('non androidx app project', () async {
- Cache.flutterRoot = '../..';
- when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
- when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
-
- final CreateCommand command = CreateCommand();
- final CommandRunner<void> runner = createTestCommandRunner(command);
-
- await runner.run(<String>['create', '--no-pub', '--no-androidx', projectDir.path]);
-
- void expectExists(String relPath) {
- expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
- }
-
- expectExists('android/gradle.properties');
-
- final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString();
-
- expect(actualContents.contains('useAndroidX'), false);
- });
-
testUsingContext('androidx is used by default in a module project', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
@@ -526,23 +505,6 @@
);
});
- testUsingContext('non androidx module', () async {
- Cache.flutterRoot = '../..';
- when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
- when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
-
- final CreateCommand command = CreateCommand();
- final CommandRunner<void> runner = createTestCommandRunner(command);
-
- await runner.run(<String>['create', '--template=module', '--no-pub', '--no-androidx', projectDir.path]);
-
- final FlutterProject project = FlutterProject.fromDirectory(projectDir);
- expect(
- project.usesAndroidX,
- false,
- );
- });
-
testUsingContext('androidx is used by default in a plugin project', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
@@ -564,27 +526,6 @@
expect(actualContents.contains('useAndroidX'), true);
});
- testUsingContext('non androidx plugin project', () async {
- Cache.flutterRoot = '../..';
- when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
- when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
-
- final CreateCommand command = CreateCommand();
- final CommandRunner<void> runner = createTestCommandRunner(command);
-
- await runner.run(<String>['create', '--no-pub', '--template=plugin', '--no-androidx', projectDir.path]);
-
- void expectExists(String relPath) {
- expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true);
- }
-
- expectExists('android/gradle.properties');
-
- final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString();
-
- expect(actualContents.contains('useAndroidX'), false);
- });
-
testUsingContext('app supports Linux if requested', () async {
Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
diff --git a/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart b/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
index bd0ae54..b475217 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
@@ -366,7 +366,13 @@
testUsingContext("reports when the app isn't using AndroidX", () async {
final String projectPath = await createProject(tempDir,
- arguments: <String>['--no-pub', '--no-androidx', '--template=app']);
+ arguments: <String>['--no-pub', '--template=app']);
+ // Simulate a non-androidx project.
+ tempDir
+ .childDirectory('flutter_project')
+ .childDirectory('android')
+ .childFile('gradle.properties')
+ .writeAsStringSync('android.useAndroidX=false');
when(mockProcessManager.start(
<String>[
diff --git a/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart b/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
index 83f54bd..539969f 100644
--- a/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
+++ b/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
@@ -324,7 +324,13 @@
testUsingContext("reports when the app isn't using AndroidX", () async {
final String projectPath = await createProject(tempDir,
- arguments: <String>['--no-pub', '--no-androidx', '--template=app']);
+ arguments: <String>['--no-pub', '--template=app']);
+ // Simulate a non-androidx project.
+ tempDir
+ .childDirectory('flutter_project')
+ .childDirectory('android')
+ .childFile('gradle.properties')
+ .writeAsStringSync('android.useAndroidX=false');
when(mockProcessManager.start(
<String>[