Add a migrator to remove FlutterMultiDexApplication.java (#148515)
Fixes https://github.com/flutter/flutter/issues/148368. See [my comment](https://github.com/flutter/flutter/issues/148368#issuecomment-2116133180) for the specific context.
This commit is contained in:
@@ -37,6 +37,7 @@ import 'gradle_utils.dart';
|
||||
import 'java.dart';
|
||||
import 'migrations/android_studio_java_gradle_conflict_migration.dart';
|
||||
import 'migrations/min_sdk_version_migration.dart';
|
||||
import 'migrations/multidex_removal_migration.dart';
|
||||
import 'migrations/top_level_gradle_build_file_migration.dart';
|
||||
|
||||
/// The regex to grab variant names from printBuildVariants gradle task
|
||||
@@ -313,6 +314,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
androidStudio: _androidStudio,
|
||||
java: globals.java),
|
||||
MinSdkVersionMigration(project.android, _logger),
|
||||
MultidexRemovalMigration(project.android, _logger),
|
||||
];
|
||||
|
||||
final ProjectMigration migration = ProjectMigration(migrators);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/project_migrator.dart';
|
||||
import '../../project.dart';
|
||||
|
||||
/// This migrator deletes an old file that was created to support enabling
|
||||
/// Multidex, which is no longer needed and causes builds to fail if not
|
||||
/// deleted.
|
||||
class MultidexRemovalMigration extends ProjectMigrator {
|
||||
|
||||
MultidexRemovalMigration(AndroidProject project, super.logger)
|
||||
: _project = project;
|
||||
|
||||
final AndroidProject _project;
|
||||
|
||||
static const String deletionMessage = 'Deleted obsolete FlutterMultiDexApplication.java file.';
|
||||
|
||||
File _getMultiDexApplicationFile() {
|
||||
return _project.hostAppGradleRoot
|
||||
.childDirectory('src')
|
||||
.childDirectory('main')
|
||||
.childDirectory('java')
|
||||
.childDirectory('io')
|
||||
.childDirectory('flutter')
|
||||
.childDirectory('app')
|
||||
.childFile('FlutterMultiDexApplication.java');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> migrate() async {
|
||||
final File multiDexApplicationFile = _getMultiDexApplicationFile();
|
||||
if (multiDexApplicationFile.existsSync()) {
|
||||
multiDexApplicationFile.deleteSync();
|
||||
logger.printTrace(deletionMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user