Revert "Revert "Use AndroidX in new projects by default (#40925)" (#40995)" (#41001)
This reverts commit 8e231796272f7f14391ca9c6b40392bc20f96aeb.
diff --git a/dev/integration_tests/android_host_app/app/build.gradle b/dev/integration_tests/android_host_app/app/build.gradle
index e95f399..7ac8837 100644
--- a/dev/integration_tests/android_host_app/app/build.gradle
+++ b/dev/integration_tests/android_host_app/app/build.gradle
@@ -14,11 +14,11 @@
targetSdkVersion 28
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation project(':flutter')
- implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
}
diff --git a/dev/integration_tests/android_host_app/app/src/main/java/io/flutter/add2app/MainActivity.java b/dev/integration_tests/android_host_app/app/src/main/java/io/flutter/add2app/MainActivity.java
index 1c3ead7..8acc10c 100644
--- a/dev/integration_tests/android_host_app/app/src/main/java/io/flutter/add2app/MainActivity.java
+++ b/dev/integration_tests/android_host_app/app/src/main/java/io/flutter/add2app/MainActivity.java
@@ -1,7 +1,7 @@
package io.flutter.add2app;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import androidx.appcompat.app.AppCompatActivity;
import io.flutter.facade.Flutter;
public class MainActivity extends AppCompatActivity {
diff --git a/dev/integration_tests/android_host_app/gradle.properties b/dev/integration_tests/android_host_app/gradle.properties
index 6ed0f8f..015c76e 100644
--- a/dev/integration_tests/android_host_app/gradle.properties
+++ b/dev/integration_tests/android_host_app/gradle.properties
@@ -1 +1,4 @@
org.gradle.jvmargs=-Xmx1536m
+
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/dev/integration_tests/module_host_with_custom_build/app/build.gradle b/dev/integration_tests/module_host_with_custom_build/app/build.gradle
index 254d777..9b7fdfb 100644
--- a/dev/integration_tests/module_host_with_custom_build/app/build.gradle
+++ b/dev/integration_tests/module_host_with_custom_build/app/build.gradle
@@ -39,5 +39,5 @@
dependencies {
implementation project(':flutter')
- implementation 'com.android.support:appcompat-v7:27.1.1'
+ implementation 'androidx.appcompat:appcompat:1.1.0'
}
diff --git a/dev/integration_tests/module_host_with_custom_build/app/src/main/java/io/flutter/addtoapp/MainActivity.java b/dev/integration_tests/module_host_with_custom_build/app/src/main/java/io/flutter/addtoapp/MainActivity.java
index 60bb318..1f5b2a2 100644
--- a/dev/integration_tests/module_host_with_custom_build/app/src/main/java/io/flutter/addtoapp/MainActivity.java
+++ b/dev/integration_tests/module_host_with_custom_build/app/src/main/java/io/flutter/addtoapp/MainActivity.java
@@ -1,7 +1,7 @@
package io.flutter.addtoapp;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import androidx.appcompat.app.AppCompatActivity;
import io.flutter.facade.Flutter;
public class MainActivity extends AppCompatActivity {
diff --git a/dev/integration_tests/module_host_with_custom_build/gradle.properties b/dev/integration_tests/module_host_with_custom_build/gradle.properties
index 6ed0f8f..015c76e 100644
--- a/dev/integration_tests/module_host_with_custom_build/gradle.properties
+++ b/dev/integration_tests/module_host_with_custom_build/gradle.properties
@@ -1 +1,4 @@
org.gradle.jvmargs=-Xmx1536m
+
+android.useAndroidX=true
+android.enableJetifier=true
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);