Unverified Commit f7173dcc authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Use AndroidX in new projects by default (#40925)

parent 96482eeb
...@@ -14,11 +14,11 @@ android { ...@@ -14,11 +14,11 @@ android {
targetSdkVersion 28 targetSdkVersion 28
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
} }
dependencies { dependencies {
implementation project(':flutter') implementation project(':flutter')
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'androidx.appcompat:appcompat:1.1.0'
} }
package io.flutter.add2app; package io.flutter.add2app;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import io.flutter.facade.Flutter; import io.flutter.facade.Flutter;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
......
org.gradle.jvmargs=-Xmx1536m org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
...@@ -39,5 +39,5 @@ android { ...@@ -39,5 +39,5 @@ android {
dependencies { dependencies {
implementation project(':flutter') implementation project(':flutter')
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'androidx.appcompat:appcompat:1.1.0'
} }
package io.flutter.addtoapp; package io.flutter.addtoapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import io.flutter.facade.Flutter; import io.flutter.facade.Flutter;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
......
org.gradle.jvmargs=-Xmx1536m org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
...@@ -141,7 +141,7 @@ class CreateCommand extends FlutterCommand { ...@@ -141,7 +141,7 @@ class CreateCommand extends FlutterCommand {
argParser.addFlag( argParser.addFlag(
'androidx', 'androidx',
negatable: true, negatable: true,
defaultsTo: false, defaultsTo: true,
help: 'Generate a project using the AndroidX support libraries', help: 'Generate a project using the AndroidX support libraries',
); );
// Deprecated // Deprecated
...@@ -398,7 +398,7 @@ class CreateCommand extends FlutterCommand { ...@@ -398,7 +398,7 @@ class CreateCommand extends FlutterCommand {
final String relativeDirPath = fs.path.relative(projectDirPath); final String relativeDirPath = fs.path.relative(projectDirPath);
if (!projectDir.existsSync() || projectDir.listSync().isEmpty) { if (!projectDir.existsSync() || projectDir.listSync().isEmpty) {
printStatus('Creating project $relativeDirPath...'); printStatus('Creating project $relativeDirPath... androidx: ${argResults['androidx']}');
} else { } else {
if (sampleCode != null && !argResults['overwrite']) { if (sampleCode != null && !argResults['overwrite']) {
throwToolExit('Will not overwrite existing project in $relativeDirPath: ' throwToolExit('Will not overwrite existing project in $relativeDirPath: '
......
...@@ -410,7 +410,7 @@ void main() { ...@@ -410,7 +410,7 @@ void main() {
}, timeout: allowForRemotePubInvocation); }, timeout: allowForRemotePubInvocation);
testUsingContext('androidx app project', () async { testUsingContext('androidx is used by default in an app project', () async {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel); when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
...@@ -418,7 +418,7 @@ void main() { ...@@ -418,7 +418,7 @@ void main() {
final CreateCommand command = CreateCommand(); final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command); 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) { void expectExists(String relPath) {
expect(fs.isFileSync('${projectDir.path}/$relPath'), true); expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
...@@ -452,7 +452,7 @@ void main() { ...@@ -452,7 +452,7 @@ void main() {
expect(actualContents.contains('useAndroidX'), false); expect(actualContents.contains('useAndroidX'), false);
}, timeout: allowForCreateFlutterProject); }, timeout: allowForCreateFlutterProject);
testUsingContext('androidx app module', () async { testUsingContext('androidx is used by default in a module project', () async {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel); when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
...@@ -460,7 +460,7 @@ void main() { ...@@ -460,7 +460,7 @@ void main() {
final CreateCommand command = CreateCommand(); final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command); 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); final FlutterProject project = FlutterProject.fromDirectory(projectDir);
expect( expect(
...@@ -469,7 +469,7 @@ void main() { ...@@ -469,7 +469,7 @@ void main() {
); );
}, timeout: allowForCreateFlutterProject); }, timeout: allowForCreateFlutterProject);
testUsingContext('non androidx app module', () async { testUsingContext('non androidx module', () async {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel); when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
...@@ -486,7 +486,7 @@ void main() { ...@@ -486,7 +486,7 @@ void main() {
); );
}, timeout: allowForCreateFlutterProject); }, timeout: allowForCreateFlutterProject);
testUsingContext('androidx plugin project', () async { testUsingContext('androidx is used by default in a plugin project', () async {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
when(mockFlutterVersion.channel).thenReturn(frameworkChannel); when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
...@@ -494,7 +494,7 @@ void main() { ...@@ -494,7 +494,7 @@ void main() {
final CreateCommand command = CreateCommand(); final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command); 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) { void expectExists(String relPath) {
expect(fs.isFileSync('${projectDir.path}/$relPath'), true); expect(fs.isFileSync('${projectDir.path}/$relPath'), true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment