Allow flutter run to run release/profile x64 (#45511)
diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart
index 38959ff..22dbcd9 100644
--- a/packages/flutter_tools/lib/src/android/android_device.dart
+++ b/packages/flutter_tools/lib/src/android/android_device.dart
@@ -491,10 +491,9 @@
}
final TargetPlatform devicePlatform = await targetPlatform;
- if (!(devicePlatform == TargetPlatform.android_arm ||
- devicePlatform == TargetPlatform.android_arm64) &&
- !debuggingOptions.buildInfo.isDebug) {
- printError('Profile and release builds are only supported on ARM targets.');
+ if (devicePlatform == TargetPlatform.android_x86 &&
+ !debuggingOptions.buildInfo.isDebug) {
+ printError('Profile and release builds are only supported on ARM/x64 targets.');
return LaunchResult.failed();
}
diff --git a/packages/flutter_tools/test/general.shard/android/android_device_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_test.dart
index 45ccaf0..a765a5b 100644
--- a/packages/flutter_tools/test/general.shard/android/android_device_test.dart
+++ b/packages/flutter_tools/test/general.shard/android/android_device_test.dart
@@ -94,12 +94,19 @@
});
group('startApp', () {
- final MockAndroidApk mockApk = MockAndroidApk();
- final MockProcessManager mockProcessManager = MockProcessManager();
- final MockAndroidSdk mockAndroidSdk = MockAndroidSdk();
- final MockProcessUtils mockProcessUtils = MockProcessUtils();
+ MockAndroidApk mockApk;
+ MockProcessManager mockProcessManager;
+ MockAndroidSdk mockAndroidSdk;
+ MockProcessUtils mockProcessUtils;
- testUsingContext(' succeeds with --cache-sksl', () async {
+ setUp(() {
+ mockApk = MockAndroidApk();
+ mockProcessManager = MockProcessManager();
+ mockAndroidSdk = MockAndroidSdk();
+ mockProcessUtils = MockProcessUtils();
+ });
+
+ testUsingContext('succeeds with --cache-sksl', () async {
const String deviceId = '1234';
final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel');
@@ -140,6 +147,41 @@
ProcessManager: () => mockProcessManager,
ProcessUtils: () => mockProcessUtils,
});
+
+ testUsingContext('can run a release build on x64', () async {
+ const String deviceId = '1234';
+ final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel');
+
+ final Directory sdkDir = MockAndroidSdk.createSdkDirectory();
+ Config.instance.setValue('android-sdk', sdkDir.path);
+ final File adbExe = fs.file(getAdbPath(androidSdk));
+
+ when(mockAndroidSdk.licensesAvailable).thenReturn(true);
+ when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion());
+
+ when(mockProcessManager.run(
+ <String>[adbExe.path, '-s', deviceId, 'shell', 'getprop'],
+ stdoutEncoding: latin1,
+ stderrEncoding: latin1,
+ )).thenAnswer((_) async {
+ return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]\n[ro.product.cpu.abi]: [x86_64]', '');
+ });
+
+ final LaunchResult launchResult = await device.startApp(
+ mockApk,
+ prebuiltApplication: true,
+ debuggingOptions: DebuggingOptions.disabled(
+ const BuildInfo(BuildMode.release, null),
+ ),
+ platformArgs: <String, dynamic>{},
+ );
+ expect(launchResult.started, true);
+ }, overrides: <Type, Generator>{
+ AndroidSdk: () => mockAndroidSdk,
+ FileSystem: () => MemoryFileSystem(),
+ ProcessManager: () => mockProcessManager,
+ ProcessUtils: () => mockProcessUtils,
+ });
});
});
@@ -378,7 +420,7 @@
ProcessManager: () => mockProcessManager
});
- testUsingContext('detects kind fire ABI', () async {
+ testUsingContext('detects kindle fire ABI', () async {
cpu = 'arm64-v8a';
abilist = 'arm';
final AndroidDevice device = AndroidDevice('test');