From 48ce60824af7199b221aa0e93ddffe7e9c6094e5 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Tue, 24 Sep 2019 16:55:09 -0700 Subject: [PATCH] Revert "Revert "Use AndroidX in new projects by default (#40925)" (#40995)" (#41001) This reverts commit 8e231796272f7f14391ca9c6b40392bc20f96aeb. --- .../android_host_app/app/build.gradle | 4 ++-- .../main/java/io/flutter/add2app/MainActivity.java | 2 +- .../android_host_app/gradle.properties | 3 +++ .../module_host_with_custom_build/app/build.gradle | 2 +- .../java/io/flutter/addtoapp/MainActivity.java | 2 +- .../gradle.properties | 3 +++ .../flutter_tools/lib/src/commands/create.dart | 4 ++-- .../test/general.shard/commands/create_test.dart | 14 +++++++------- 8 files changed, 20 insertions(+), 14 deletions(-) diff --git a/dev/integration_tests/android_host_app/app/build.gradle b/dev/integration_tests/android_host_app/app/build.gradle index e95f3992837..7ac88376905 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 @@ android { 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 1c3ead7a992..8acc10cf0bc 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 6ed0f8f9609..015c76e2afa 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 254d777b3ff..9b7fdfb5410 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 @@ android { 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 60bb318ab40..1f5b2a2bd4f 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 6ed0f8f9609..015c76e2afa 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 2e5ad130d9c..4c35620d0b0 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -141,7 +141,7 @@ class CreateCommand extends FlutterCommand { argParser.addFlag( 'androidx', negatable: true, - defaultsTo: false, + defaultsTo: true, help: 'Generate a project using the AndroidX support libraries', ); // Deprecated @@ -398,7 +398,7 @@ class CreateCommand extends FlutterCommand { 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 eb573233ad8..1cb66504dc5 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 @@ void main() { }, 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 @@ void main() { final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); - await runner.run(['create', '--no-pub', '--androidx', projectDir.path]); + await runner.run(['create', '--no-pub', projectDir.path]); void expectExists(String relPath) { expect(fs.isFileSync('${projectDir.path}/$relPath'), true); @@ -459,7 +459,7 @@ void main() { 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 @@ void main() { final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); - await runner.run(['create', '--template=module', '--no-pub', '--androidx', projectDir.path]); + await runner.run(['create', '--template=module', '--no-pub', projectDir.path]); final FlutterProject project = FlutterProject.fromDirectory(projectDir); expect( @@ -476,7 +476,7 @@ void main() { ); }, 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 @@ void main() { ); }, 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 @@ void main() { final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); - await runner.run(['create', '--no-pub', '--template=plugin', '--androidx', projectDir.path]); + await runner.run(['create', '--no-pub', '--template=plugin', projectDir.path]); void expectExists(String relPath) { expect(fs.isFileSync('${projectDir.path}/$relPath'), true);