This reverts commit 8e73bab94c.
This commit is contained in:
@@ -27,7 +27,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,7 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
this.project = project
|
||||
|
||||
project.extensions.create("flutter", FlutterExtension)
|
||||
this.addFlutterTasks(project)
|
||||
|
||||
project.afterEvaluate this.&addFlutterTasks
|
||||
// By default, assembling APKs generates fat APKs if multiple platforms are passed.
|
||||
// Configuring split per ABI allows to generate separate APKs for each abi.
|
||||
// This is a noop when building a bundle.
|
||||
@@ -159,23 +158,24 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
String flutterProguardRules = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
|
||||
"gradle", "flutter_proguard_rules.pro")
|
||||
project.android.buildTypes {
|
||||
release {
|
||||
// Enables code shrinking, obfuscation, and optimization for only
|
||||
// your project's release build type.
|
||||
minifyEnabled true
|
||||
// Enables resource shrinking, which is performed by the
|
||||
// Android Gradle plugin.
|
||||
// NOTE: The resource shrinker can't be used for libraries.
|
||||
shrinkResources isBuiltAsApp(project)
|
||||
// Fallback to `android/app/proguard-rules.pro`.
|
||||
// This way, custom Proguard rules can be configured as needed.
|
||||
proguardFiles project.android.getDefaultProguardFile("proguard-android.txt"), flutterProguardRules, "proguard-rules.pro"
|
||||
if (shouldShrinkResources(project)) {
|
||||
String flutterProguardRules = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
|
||||
"gradle", "flutter_proguard_rules.pro")
|
||||
project.android.buildTypes {
|
||||
release {
|
||||
// Enables code shrinking, obfuscation, and optimization for only
|
||||
// your project's release build type.
|
||||
minifyEnabled true
|
||||
// Enables resource shrinking, which is performed by the
|
||||
// Android Gradle plugin.
|
||||
// NOTE: The resource shrinker can't be used for libraries.
|
||||
shrinkResources isBuiltAsApp(project)
|
||||
// Fallback to `android/app/proguard-rules.pro`.
|
||||
// This way, custom Proguard rules can be configured as needed.
|
||||
proguardFiles project.android.getDefaultProguardFile("proguard-android.txt"), flutterProguardRules, "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useLocalEngine()) {
|
||||
// This is required to pass the local engine to flutter build aot.
|
||||
String engineOutPath = project.property('local-engine-out')
|
||||
@@ -322,13 +322,13 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
)
|
||||
}
|
||||
pluginProject.afterEvaluate {
|
||||
pluginProject.android.buildTypes {
|
||||
profile {
|
||||
initWith debug
|
||||
}
|
||||
}
|
||||
pluginProject.android.buildTypes.each addEmbeddingCompileOnlyDependency
|
||||
pluginProject.android.buildTypes.whenObjectAdded addEmbeddingCompileOnlyDependency
|
||||
pluginProject.android.buildTypes {
|
||||
profile {
|
||||
initWith debug
|
||||
}
|
||||
}
|
||||
pluginProject.android.buildTypes.each addEmbeddingCompileOnlyDependency
|
||||
pluginProject.android.buildTypes.whenObjectAdded addEmbeddingCompileOnlyDependency
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,6 +490,14 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
private static Boolean shouldShrinkResources(Project project) {
|
||||
if (project.hasProperty("shrink")) {
|
||||
return project.property("shrink").toBoolean()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private static Boolean isBuiltAsApp(Project project) {
|
||||
// Projects are built as applications when the they use the `com.android.application`
|
||||
// plugin.
|
||||
@@ -562,21 +570,13 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
return "${targetArch}-release"
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the directory that contains the Flutter source code.
|
||||
* This is the the directory containing the `android/` directory.
|
||||
*/
|
||||
private File getFlutterSourceDirectory() {
|
||||
private void addFlutterTasks(Project project) {
|
||||
if (project.state.failure) {
|
||||
return
|
||||
}
|
||||
if (project.flutter.source == null) {
|
||||
throw new GradleException("Must provide Flutter source directory")
|
||||
}
|
||||
return project.file(project.flutter.source)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target file. This is typically `lib/main.dart`.
|
||||
*/
|
||||
private String getFlutterTarget() {
|
||||
String target = project.flutter.target
|
||||
if (target == null) {
|
||||
target = 'lib/main.dart'
|
||||
@@ -584,66 +584,6 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
if (project.hasProperty('target')) {
|
||||
target = project.property('target')
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
// In AGP 4.0, the Android linter task depends on the JAR tasks that generate `libapp.so`.
|
||||
// When building APKs, this causes an issue where building release requires the debug JAR,
|
||||
// but Gradle won't build debug.
|
||||
//
|
||||
// To workaround this issue, only configure the JAR task that is required given the task
|
||||
// from the command line.
|
||||
//
|
||||
// The AGP team said that this issue is fixed in Gradle 7.0, which isn't released at the
|
||||
// time of adding this code. Once released, this can be removed.
|
||||
//
|
||||
// Tested cases:
|
||||
// * `./gradlew assembleRelease`
|
||||
// * `./gradlew app:assembleRelease.`
|
||||
// * `./gradlew assemble{flavorName}Release`
|
||||
// * `./gradlew app:assemble{flavorName}Release`
|
||||
// * `./gradlew assemble.`
|
||||
// * `./gradlew app:assemble.`
|
||||
// * `./gradlew bundle.`
|
||||
// * `./gradlew bundleRelease.`
|
||||
// * `./gradlew app:bundleRelease.`
|
||||
//
|
||||
// Related issues:
|
||||
// https://issuetracker.google.com/issues/158060799
|
||||
// https://issuetracker.google.com/issues/158753935
|
||||
private boolean shouldConfigureFlutterTask(Task assembleTask) {
|
||||
def cliTasksNames = project.gradle.startParameter.taskNames
|
||||
if (cliTasksNames.size() != 1 || !cliTasksNames.first().contains("assemble")) {
|
||||
return true
|
||||
}
|
||||
def taskName = cliTasksNames.first().split(":").last()
|
||||
if (taskName == "assemble") {
|
||||
return true
|
||||
}
|
||||
if (taskName == assembleTask.name) {
|
||||
return true
|
||||
}
|
||||
if (taskName.endsWith("Release") && assembleTask.name.endsWith("Release")) {
|
||||
return true
|
||||
}
|
||||
if (taskName.endsWith("Debug") && assembleTask.name.endsWith("Debug")) {
|
||||
return true
|
||||
}
|
||||
if (taskName.endsWith("Profile") && assembleTask.name.endsWith("Profile")) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private Task getAssembleTask(variant) {
|
||||
// `assemble` became `assembleProvider` in AGP 3.3.0.
|
||||
return variant.hasProperty("assembleProvider") ? variant.assembleProvider.get() : variant.assemble
|
||||
}
|
||||
|
||||
private void addFlutterTasks(Project project) {
|
||||
if (project.state.failure) {
|
||||
return
|
||||
}
|
||||
String[] fileSystemRootsValue = null
|
||||
if (project.hasProperty('filesystem-roots')) {
|
||||
fileSystemRootsValue = project.property('filesystem-roots').split('\\|')
|
||||
@@ -715,14 +655,14 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
buildMode variantBuildMode
|
||||
localEngine this.localEngine
|
||||
localEngineSrcPath this.localEngineSrcPath
|
||||
targetPath getFlutterTarget()
|
||||
targetPath target
|
||||
verbose isVerbose()
|
||||
fastStart isFastStart()
|
||||
fileSystemRoots fileSystemRootsValue
|
||||
fileSystemScheme fileSystemSchemeValue
|
||||
trackWidgetCreation trackWidgetCreationValue
|
||||
targetPlatformValues = targetPlatforms
|
||||
sourceDir getFlutterSourceDirectory()
|
||||
sourceDir project.file(project.flutter.source)
|
||||
intermediateDir project.file("${project.buildDir}/${AndroidProject.FD_INTERMEDIATES}/flutter/${variant.name}/")
|
||||
extraFrontEndOptions extraFrontEndOptionsValue
|
||||
extraGenSnapshotOptions extraGenSnapshotOptionsValue
|
||||
@@ -794,22 +734,48 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
def processResources = variantOutput.hasProperty("processResourcesProvider") ?
|
||||
variantOutput.processResourcesProvider.get() : variantOutput.processResources
|
||||
processResources.dependsOn(copyFlutterAssetsTask)
|
||||
return
|
||||
}
|
||||
return copyFlutterAssetsTask
|
||||
}
|
||||
boolean isFlutterAppProject = project.android.hasProperty("applicationVariants")
|
||||
if (isFlutterAppProject) {
|
||||
project.android.applicationVariants.all { variant ->
|
||||
Task assembleTask = getAssembleTask(variant)
|
||||
if (!shouldConfigureFlutterTask(assembleTask)) {
|
||||
return
|
||||
// Flutter module included as a subproject in add to app.
|
||||
String hostAppProjectName = project.rootProject.hasProperty('flutter.hostAppProjectName') ? project.rootProject.property('flutter.hostAppProjectName') : "app"
|
||||
Project appProject = project.rootProject.findProject(":${hostAppProjectName}")
|
||||
assert appProject != null : "Project :${hostAppProjectName} doesn't exist. To custom the host app project name, set `org.gradle.project.flutter.hostAppProjectName=<project-name>` in gradle.properties."
|
||||
appProject.afterEvaluate {
|
||||
assert appProject.android != null
|
||||
appProject.android.applicationVariants.all { appProjectVariant ->
|
||||
// Find a compatible application variant in the host app.
|
||||
//
|
||||
// For example, consider a host app that defines the following variants:
|
||||
// | ----------------- | ----------------------------- |
|
||||
// | Build Variant | Flutter Equivalent Variant |
|
||||
// | ----------------- | ----------------------------- |
|
||||
// | freeRelease | relese |
|
||||
// | freeDebug | debug |
|
||||
// | freeDevelop | debug |
|
||||
// | profile | profile |
|
||||
// | ----------------- | ----------------------------- |
|
||||
//
|
||||
// This mapping is based on the following rules:
|
||||
// 1. If the host app build variant name is `profile` then the equivalent
|
||||
// Flutter variant is `profile`.
|
||||
// 2. If the host app build variant is debuggable
|
||||
// (e.g. `buildType.debuggable = true`), then the equivalent Flutter
|
||||
// variant is `debug`.
|
||||
// 3. Otherwise, the equivalent Flutter variant is `release`.
|
||||
if (buildModeFor(appProjectVariant.buildType) != variantBuildMode) {
|
||||
return
|
||||
}
|
||||
Task mergeAssets = project
|
||||
.tasks
|
||||
.findByPath(":${hostAppProjectName}:merge${appProjectVariant.name.capitalize()}Assets")
|
||||
assert mergeAssets
|
||||
mergeAssets.dependsOn(copyFlutterAssetsTask)
|
||||
}
|
||||
Task copyFlutterAssetsTask = addFlutterDeps(variant)
|
||||
def variantOutput = variant.outputs.first()
|
||||
def processResources = variantOutput.hasProperty("processResourcesProvider") ?
|
||||
variantOutput.processResourcesProvider.get() : variantOutput.processResources
|
||||
processResources.dependsOn(copyFlutterAssetsTask)
|
||||
|
||||
}
|
||||
}
|
||||
if (project.android.hasProperty("applicationVariants")) {
|
||||
project.android.applicationVariants.all { variant ->
|
||||
addFlutterDeps(variant)
|
||||
// Copy the output APKs into a known location, so `flutter run` or `flutter build apk`
|
||||
// can discover them. By default, this is `<app-dir>/build/app/outputs/flutter-apk/<filename>.apk`.
|
||||
//
|
||||
@@ -819,6 +785,10 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
// * `flavor-name` is the flavor used to build the app in lower case if the assemble task is called.
|
||||
// * `build-mode` can be `release|debug|profile`.
|
||||
variant.outputs.all { output ->
|
||||
// `assemble` became `assembleProvider` in AGP 3.3.0.
|
||||
def assembleTask = variant.hasProperty("assembleProvider")
|
||||
? variant.assembleProvider.get()
|
||||
: variant.assemble
|
||||
assembleTask.doLast {
|
||||
// `packageApplication` became `packageApplicationProvider` in AGP 3.3.0.
|
||||
def outputDirectory = variant.hasProperty("packageApplicationProvider")
|
||||
@@ -847,56 +817,8 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
configurePlugins()
|
||||
return
|
||||
}
|
||||
// Flutter host module project (Add-to-app).
|
||||
String hostAppProjectName = project.rootProject.hasProperty('flutter.hostAppProjectName') ? project.rootProject.property('flutter.hostAppProjectName') : "app"
|
||||
Project appProject = project.rootProject.findProject(":${hostAppProjectName}")
|
||||
assert appProject != null : "Project :${hostAppProjectName} doesn't exist. To custom the host app project name, set `org.gradle.project.flutter.hostAppProjectName=<project-name>` in gradle.properties."
|
||||
// Wait for the host app project configuration.
|
||||
appProject.afterEvaluate {
|
||||
assert appProject.android != null
|
||||
project.android.libraryVariants.all { libraryVariant ->
|
||||
Task copyFlutterAssetsTask
|
||||
appProject.android.applicationVariants.all { appProjectVariant ->
|
||||
Task appAssembleTask = getAssembleTask(appProjectVariant)
|
||||
if (!shouldConfigureFlutterTask(appAssembleTask)) {
|
||||
return
|
||||
}
|
||||
// Find a compatible application variant in the host app.
|
||||
//
|
||||
// For example, consider a host app that defines the following variants:
|
||||
// | ----------------- | ----------------------------- |
|
||||
// | Build Variant | Flutter Equivalent Variant |
|
||||
// | ----------------- | ----------------------------- |
|
||||
// | freeRelease | relese |
|
||||
// | freeDebug | debug |
|
||||
// | freeDevelop | debug |
|
||||
// | profile | profile |
|
||||
// | ----------------- | ----------------------------- |
|
||||
//
|
||||
// This mapping is based on the following rules:
|
||||
// 1. If the host app build variant name is `profile` then the equivalent
|
||||
// Flutter variant is `profile`.
|
||||
// 2. If the host app build variant is debuggable
|
||||
// (e.g. `buildType.debuggable = true`), then the equivalent Flutter
|
||||
// variant is `debug`.
|
||||
// 3. Otherwise, the equivalent Flutter variant is `release`.
|
||||
String variantBuildMode = buildModeFor(libraryVariant.buildType)
|
||||
if (buildModeFor(appProjectVariant.buildType) != variantBuildMode) {
|
||||
return
|
||||
}
|
||||
if (copyFlutterAssetsTask == null) {
|
||||
copyFlutterAssetsTask = addFlutterDeps(libraryVariant)
|
||||
}
|
||||
Task mergeAssets = project
|
||||
.tasks
|
||||
.findByPath(":${hostAppProjectName}:merge${appProjectVariant.name.capitalize()}Assets")
|
||||
assert mergeAssets
|
||||
mergeAssets.dependsOn(copyFlutterAssetsTask)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
project.android.libraryVariants.all addFlutterDeps
|
||||
}
|
||||
configurePlugins()
|
||||
}
|
||||
|
||||
@@ -324,6 +324,9 @@ Future<void> buildGradleApp({
|
||||
if (androidBuildInfo.splitPerAbi) {
|
||||
command.add('-Psplit-per-abi=true');
|
||||
}
|
||||
if (androidBuildInfo.shrink) {
|
||||
command.add('-Pshrink=true');
|
||||
}
|
||||
if (androidBuildInfo.buildInfo.dartDefines?.isNotEmpty ?? false) {
|
||||
command.add('-Pdart-defines=${encodeDartDefines(androidBuildInfo.buildInfo.dartDefines)}');
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ final GradleHandledError androidXFailureHandler = GradleHandledError(
|
||||
}
|
||||
if (hasPlugins && usesAndroidX && !shouldBuildPluginAsAar) {
|
||||
globals.printStatus(
|
||||
'The build failed likely due to AndroidX incompatibilities in a plugin. '
|
||||
'The built failed likely due to AndroidX incompatibilities in a plugin. '
|
||||
'The tool is about to try using Jetfier to solve the incompatibility.'
|
||||
);
|
||||
BuildEvent(
|
||||
|
||||
@@ -40,6 +40,9 @@ class GradleUtils {
|
||||
/// This is the `gradlew` or `gradlew.bat` script in the `android/` directory.
|
||||
String getExecutable(FlutterProject project) {
|
||||
final Directory androidDir = project.android.hostAppGradleRoot;
|
||||
// Update the project if needed.
|
||||
// TODO(egarciad): https://github.com/flutter/flutter/issues/40460
|
||||
gradleUtils.migrateToR8(androidDir);
|
||||
gradleUtils.injectGradleWrapperIfNeeded(androidDir);
|
||||
|
||||
final File gradle = androidDir.childFile(
|
||||
@@ -59,6 +62,37 @@ class GradleUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Migrates the Android's [directory] to R8.
|
||||
/// https://developer.android.com/studio/build/shrink-code
|
||||
@visibleForTesting
|
||||
void migrateToR8(Directory directory) {
|
||||
final File gradleProperties = directory.childFile('gradle.properties');
|
||||
if (!gradleProperties.existsSync()) {
|
||||
throwToolExit(
|
||||
'Expected file ${gradleProperties.path}. '
|
||||
'Please ensure that this file exists or that ${gradleProperties.dirname} can be read.'
|
||||
);
|
||||
}
|
||||
final String propertiesContent = gradleProperties.readAsStringSync();
|
||||
if (propertiesContent.contains('android.enableR8')) {
|
||||
globals.printTrace('gradle.properties already sets `android.enableR8`');
|
||||
return;
|
||||
}
|
||||
globals.printTrace('set `android.enableR8=true` in gradle.properties');
|
||||
try {
|
||||
if (propertiesContent.isNotEmpty && !propertiesContent.endsWith('\n')) {
|
||||
// Add a new line if the file doesn't end with a new line.
|
||||
gradleProperties.writeAsStringSync('\n', mode: FileMode.append);
|
||||
}
|
||||
gradleProperties.writeAsStringSync('android.enableR8=true\n', mode: FileMode.append);
|
||||
} on FileSystemException {
|
||||
throwToolExit(
|
||||
'The tool failed to add `android.enableR8=true` to ${gradleProperties.path}. '
|
||||
'Please update the file manually and try this command again.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Injects the Gradle wrapper files if any of these files don't exist in [directory].
|
||||
void injectGradleWrapperIfNeeded(Directory directory) {
|
||||
globals.fsUtils.copyDirectorySync(
|
||||
@@ -92,7 +126,7 @@ distributionUrl=https\\://services.gradle.org/distributions/gradle-$gradleVersio
|
||||
}
|
||||
}
|
||||
}
|
||||
const String _defaultGradleVersion = '6.7';
|
||||
const String _defaultGradleVersion = '5.6.2';
|
||||
|
||||
final RegExp _androidPluginRegExp = RegExp(r'com\.android\.tools\.build:gradle:\(\d+\.\d+\.\d+\)');
|
||||
|
||||
@@ -191,9 +225,6 @@ String getGradleVersionFor(String androidPluginVersion) {
|
||||
if (_isWithinVersionRange(androidPluginVersion, min: '3.4.0', max: '3.5.0')) {
|
||||
return '5.6.2';
|
||||
}
|
||||
if (_isWithinVersionRange(androidPluginVersion, min: '4.0.0', max: '4.1.0')) {
|
||||
return '6.7';
|
||||
}
|
||||
throwToolExit('Unsupported Android Plugin version: $androidPluginVersion.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ class AndroidBuildInfo {
|
||||
AndroidArch.x86_64,
|
||||
],
|
||||
this.splitPerAbi = false,
|
||||
this.shrink = false,
|
||||
this.fastStart = false,
|
||||
});
|
||||
|
||||
@@ -235,6 +236,9 @@ class AndroidBuildInfo {
|
||||
/// will be produced.
|
||||
final bool splitPerAbi;
|
||||
|
||||
/// Whether to enable code shrinking on release mode.
|
||||
final bool shrink;
|
||||
|
||||
/// The target platforms for the build.
|
||||
final Iterable<AndroidArch> targetArchs;
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ class BuildApkCommand extends BuildSubCommand {
|
||||
buildInfo,
|
||||
splitPerAbi: boolArg('split-per-abi'),
|
||||
targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName),
|
||||
shrink: boolArg('shrink'),
|
||||
);
|
||||
validateBuild(androidBuildInfo);
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
|
||||
}
|
||||
final AndroidBuildInfo androidBuildInfo = AndroidBuildInfo(await getBuildInfo(),
|
||||
targetArchs: stringsArg('target-platform').map<AndroidArch>(getAndroidArchForName),
|
||||
shrink: boolArg('shrink'),
|
||||
);
|
||||
validateBuild(androidBuildInfo);
|
||||
await androidBuilder.buildAab(
|
||||
|
||||
@@ -587,10 +587,14 @@ abstract class FlutterCommand extends Command<void> {
|
||||
void addShrinkingFlag() {
|
||||
argParser.addFlag('shrink',
|
||||
negatable: true,
|
||||
hide: true,
|
||||
help: 'This flag is deprecated. Code shrinking is always enabled in release builds. '
|
||||
'To learn more, see: https://developer.android.com/studio/build/shrink-code'
|
||||
);
|
||||
defaultsTo: true,
|
||||
help: 'Whether to enable code shrinking on release mode. '
|
||||
'When enabling shrinking, you also benefit from obfuscation, '
|
||||
'which shortens the names of your app’s classes and members, '
|
||||
'and optimization, which applies more aggressive strategies to '
|
||||
'further reduce the size of your app. '
|
||||
'To learn more, see: https://developer.android.com/studio/build/shrink-code',
|
||||
);
|
||||
}
|
||||
|
||||
void addNullSafetyModeOptions({ @required bool hide }) {
|
||||
|
||||
@@ -25,13 +25,17 @@ apply plugin: 'com.android.application'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "{{androidIdentifier}}"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 29
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,17 +26,21 @@ apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "{{androidIdentifier}}"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 29
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ def flutterPluginVersion = 'managed'
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility 1.8
|
||||
@@ -13,7 +13,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "{{androidIdentifier}}.host"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ group '{{androidIdentifier}}'
|
||||
version '1.0'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 29
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,12 @@ rootProject.allprojects {
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
@@ -33,6 +33,9 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||
|
||||
@@ -237,6 +237,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
@@ -265,6 +266,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Psplit-debug-info=${tempDir.path}',
|
||||
'-Ptree-shake-icons=true',
|
||||
'assembleRelease',
|
||||
@@ -298,6 +300,7 @@ void main() {
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pextra-front-end-options=foo,bar',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
@@ -353,6 +356,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
@@ -420,6 +424,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
@@ -476,6 +481,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
|
||||
@@ -207,6 +207,131 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testUsingContext('shrinking is enabled by default on release mode', () async {
|
||||
final String projectPath = await createProject(
|
||||
tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app'],
|
||||
);
|
||||
|
||||
await expectLater(() async {
|
||||
await runBuildAppBundleCommand(projectPath);
|
||||
}, throwsToolExit(message: 'Gradle task bundleRelease failed with exit code 1'));
|
||||
|
||||
verify(mockProcessManager.start(
|
||||
<String>[
|
||||
gradlew,
|
||||
'-q',
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'bundleRelease',
|
||||
],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
testUsingContext('shrinking is disabled when --no-shrink is passed', () async {
|
||||
final String projectPath = await createProject(
|
||||
tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app'],
|
||||
);
|
||||
|
||||
await expectLater(() async {
|
||||
await runBuildAppBundleCommand(
|
||||
projectPath,
|
||||
arguments: <String>['--no-shrink'],
|
||||
);
|
||||
}, throwsToolExit(message: 'Gradle task bundleRelease failed with exit code 1'));
|
||||
|
||||
verify(mockProcessManager.start(
|
||||
<String>[
|
||||
gradlew,
|
||||
'-q',
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'bundleRelease',
|
||||
],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).called(1);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
testUsingContext('guides the user when the shrinker fails', () async {
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app']);
|
||||
when(mockProcessManager.start(
|
||||
<String>[
|
||||
gradlew,
|
||||
'-q',
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'-Ptree-shake-icons=true',
|
||||
'bundleRelease',
|
||||
],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenAnswer((_) {
|
||||
const String r8StdoutWarning =
|
||||
"Execution failed for task ':app:transformClassesAndResourcesWithR8ForStageInternal'.\n"
|
||||
'> com.android.tools.r8.CompilationFailedException: Compilation failed to complete';
|
||||
return Future<Process>.value(
|
||||
createMockProcess(
|
||||
exitCode: 1,
|
||||
stdout: r8StdoutWarning,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
await expectLater(() async {
|
||||
await runBuildAppBundleCommand(
|
||||
projectPath,
|
||||
);
|
||||
}, throwsToolExit(message: 'Gradle task bundleRelease failed with exit code 1'));
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
containsIgnoringWhitespace('The shrinker may have failed to optimize the Java bytecode.'),
|
||||
);
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
containsIgnoringWhitespace('To disable the shrinker, pass the `--no-shrink` flag to this command.'),
|
||||
);
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
containsIgnoringWhitespace('To learn more, see: https://developer.android.com/studio/build/shrink-code'),
|
||||
);
|
||||
|
||||
verify(mockUsage.sendEvent(
|
||||
'build',
|
||||
'appbundle',
|
||||
label: 'gradle-r8-failure',
|
||||
parameters: anyNamed('parameters'),
|
||||
)).called(1);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Usage: () => mockUsage,
|
||||
});
|
||||
|
||||
testUsingContext("reports when the app isn't using AndroidX", () async {
|
||||
final String projectPath = await createProject(tempDir,
|
||||
arguments: <String>['--no-pub', '--template=app']);
|
||||
@@ -224,6 +349,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
@@ -279,6 +405,7 @@ void main() {
|
||||
'-Ptarget-platform=android-arm,android-arm64,android-x64',
|
||||
'-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}',
|
||||
'-Ptrack-widget-creation=true',
|
||||
'-Pshrink=true',
|
||||
'assembleRelease',
|
||||
],
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
|
||||
@@ -2115,7 +2115,7 @@ void main() {
|
||||
expect(env['flutter'].allows(Version(1, 19, 0)), false);
|
||||
});
|
||||
|
||||
testUsingContext('default app uses Android SDK 30', () async {
|
||||
testUsingContext('default app uses Android sdk 29', () async {
|
||||
Cache.flutterRoot = '../..';
|
||||
when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);
|
||||
when(mockFlutterVersion.channel).thenReturn(frameworkChannel);
|
||||
@@ -2129,8 +2129,8 @@ void main() {
|
||||
|
||||
final String buildContent = await globals.fs.file(projectDir.path + '/android/app/build.gradle').readAsString();
|
||||
|
||||
expect(buildContent.contains('compileSdkVersion 30'), true);
|
||||
expect(buildContent.contains('targetSdkVersion 30'), true);
|
||||
expect(buildContent.contains('compileSdkVersion 29'), true);
|
||||
expect(buildContent.contains('targetSdkVersion 29'), true);
|
||||
});
|
||||
|
||||
testUsingContext('Linux plugins handle partially camel-case project names correctly', () async {
|
||||
|
||||
@@ -441,7 +441,7 @@ Command: /home/android/gradlew assembleRelease
|
||||
|
||||
expect(testLogger.statusText,
|
||||
contains(
|
||||
'The build failed likely due to AndroidX incompatibilities in a plugin. '
|
||||
'The built failed likely due to AndroidX incompatibilities in a plugin. '
|
||||
'The tool is about to try using Jetfier to solve the incompatibility.'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -316,7 +316,7 @@ void main() {
|
||||
any,
|
||||
label: 'gradle-expected-file-not-found',
|
||||
parameters: const <String, String> {
|
||||
'cd37': 'androidGradlePluginVersion: 6.7, fileExtension: .aab',
|
||||
'cd37': 'androidGradlePluginVersion: 5.6.2, fileExtension: .aab',
|
||||
},
|
||||
),
|
||||
).called(1);
|
||||
@@ -771,9 +771,6 @@ flutter:
|
||||
|
||||
expect(getGradleVersionFor('3.4.0'), '5.6.2');
|
||||
expect(getGradleVersionFor('3.5.0'), '5.6.2');
|
||||
|
||||
expect(getGradleVersionFor('4.0.0'), '6.7');
|
||||
expect(getGradleVersionFor('4.1.0'), '6.7');
|
||||
});
|
||||
|
||||
testWithoutContext('throws on unsupported versions', () {
|
||||
|
||||
@@ -70,7 +70,7 @@ void main() {
|
||||
'distributionPath=wrapper/dists\n'
|
||||
'zipStoreBase=GRADLE_USER_HOME\n'
|
||||
'zipStorePath=wrapper/dists\n'
|
||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.7-all.zip\n');
|
||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-5.6.2-all.zip\n');
|
||||
}, overrides: <Type, Generator>{
|
||||
Cache: () => Cache.test(rootOverride: tempDir, fileSystem: memoryFileSystem),
|
||||
FileSystem: () => memoryFileSystem,
|
||||
@@ -111,7 +111,7 @@ void main() {
|
||||
'distributionPath=wrapper/dists\n'
|
||||
'zipStoreBase=GRADLE_USER_HOME\n'
|
||||
'zipStorePath=wrapper/dists\n'
|
||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.7-all.zip\n');
|
||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-5.6.2-all.zip\n');
|
||||
}, overrides: <Type, Generator>{
|
||||
Cache: () => Cache.test(rootOverride: tempDir, fileSystem: memoryFileSystem),
|
||||
FileSystem: () => memoryFileSystem,
|
||||
@@ -119,6 +119,108 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
group('migrateToR8', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem.test();
|
||||
});
|
||||
|
||||
testUsingContext("throws ToolExit if gradle.properties doesn't exist", () {
|
||||
final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
|
||||
sampleAppAndroid.createSync(recursive: true);
|
||||
|
||||
expect(() {
|
||||
gradleUtils.migrateToR8(sampleAppAndroid);
|
||||
}, throwsToolExit(message: 'Expected file ${sampleAppAndroid.path}'));
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('throws ToolExit if it cannot write gradle.properties', () {
|
||||
final MockDirectory sampleAppAndroid = MockDirectory();
|
||||
final MockFile gradleProperties = MockFile();
|
||||
|
||||
when(gradleProperties.path).thenReturn('foo/gradle.properties');
|
||||
when(gradleProperties.existsSync()).thenReturn(true);
|
||||
when(gradleProperties.readAsStringSync()).thenReturn('');
|
||||
when(gradleProperties.writeAsStringSync('android.enableR8=true\n', mode: FileMode.append))
|
||||
.thenThrow(const FileSystemException());
|
||||
|
||||
when(sampleAppAndroid.childFile('gradle.properties'))
|
||||
.thenReturn(gradleProperties);
|
||||
|
||||
expect(() {
|
||||
gradleUtils.migrateToR8(sampleAppAndroid);
|
||||
},
|
||||
throwsToolExit(message:
|
||||
'The tool failed to add `android.enableR8=true` to foo/gradle.properties. '
|
||||
'Please update the file manually and try this command again.'));
|
||||
});
|
||||
|
||||
testUsingContext('does not update gradle.properties if it already uses R8', () {
|
||||
final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
|
||||
sampleAppAndroid.createSync(recursive: true);
|
||||
sampleAppAndroid.childFile('gradle.properties')
|
||||
.writeAsStringSync('android.enableR8=true');
|
||||
|
||||
gradleUtils.migrateToR8(sampleAppAndroid);
|
||||
|
||||
expect(testLogger.traceText,
|
||||
contains('gradle.properties already sets `android.enableR8`'));
|
||||
expect(sampleAppAndroid.childFile('gradle.properties').readAsStringSync(),
|
||||
equals('android.enableR8=true'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('sets android.enableR8=true', () {
|
||||
final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
|
||||
sampleAppAndroid.createSync(recursive: true);
|
||||
sampleAppAndroid.childFile('gradle.properties')
|
||||
.writeAsStringSync('org.gradle.jvmargs=-Xmx1536M\n');
|
||||
|
||||
gradleUtils.migrateToR8(sampleAppAndroid);
|
||||
|
||||
expect(testLogger.traceText, contains('set `android.enableR8=true` in gradle.properties'));
|
||||
expect(
|
||||
sampleAppAndroid.childFile('gradle.properties').readAsStringSync(),
|
||||
equals(
|
||||
'org.gradle.jvmargs=-Xmx1536M\n'
|
||||
'android.enableR8=true\n'
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('appends android.enableR8=true to the new line', () {
|
||||
final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android');
|
||||
sampleAppAndroid.createSync(recursive: true);
|
||||
sampleAppAndroid.childFile('gradle.properties')
|
||||
.writeAsStringSync('org.gradle.jvmargs=-Xmx1536M');
|
||||
|
||||
gradleUtils.migrateToR8(sampleAppAndroid);
|
||||
|
||||
expect(testLogger.traceText, contains('set `android.enableR8=true` in gradle.properties'));
|
||||
expect(
|
||||
sampleAppAndroid.childFile('gradle.properties').readAsStringSync(),
|
||||
equals(
|
||||
'org.gradle.jvmargs=-Xmx1536M\n'
|
||||
'android.enableR8=true\n'
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => memoryFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any()
|
||||
});
|
||||
});
|
||||
|
||||
group('GradleUtils.getExecutable', () {
|
||||
final String gradlewFilename = globals.platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
|
||||
@@ -139,6 +241,7 @@ void main() {
|
||||
androidDirectory.childFile('gradle.properties').createSync();
|
||||
|
||||
when(gradleUtils.injectGradleWrapperIfNeeded(any)).thenReturn(null);
|
||||
when(gradleUtils.migrateToR8(any)).thenReturn(null);
|
||||
|
||||
expect(
|
||||
GradleUtils().getExecutable(FlutterProject.current()),
|
||||
@@ -170,6 +273,7 @@ void main() {
|
||||
when(androidProject.hostAppGradleRoot).thenReturn(androidDirectory);
|
||||
|
||||
when(gradleUtils.injectGradleWrapperIfNeeded(any)).thenReturn(null);
|
||||
when(gradleUtils.migrateToR8(any)).thenReturn(null);
|
||||
|
||||
GradleUtils().getExecutable(flutterProject);
|
||||
|
||||
@@ -200,6 +304,7 @@ void main() {
|
||||
when(androidProject.hostAppGradleRoot).thenReturn(androidDirectory);
|
||||
|
||||
when(gradleUtils.injectGradleWrapperIfNeeded(any)).thenReturn(null);
|
||||
when(gradleUtils.migrateToR8(any)).thenReturn(null);
|
||||
|
||||
GradleUtils().getExecutable(flutterProject);
|
||||
|
||||
@@ -230,6 +335,7 @@ void main() {
|
||||
when(androidProject.hostAppGradleRoot).thenReturn(androidDirectory);
|
||||
|
||||
when(gradleUtils.injectGradleWrapperIfNeeded(any)).thenReturn(null);
|
||||
when(gradleUtils.migrateToR8(any)).thenReturn(null);
|
||||
|
||||
GradleUtils().getExecutable(flutterProject);
|
||||
|
||||
|
||||
@@ -919,7 +919,7 @@ String gradleFileWithApplicationId(String id) {
|
||||
return '''
|
||||
apply plugin: 'com.android.application'
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
applicationId '$id'
|
||||
@@ -936,7 +936,7 @@ version '1.0-SNAPSHOT'
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 29
|
||||
}
|
||||
''';
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ void main() {
|
||||
'apk',
|
||||
'--debug',
|
||||
'--target-platform', 'android-arm',
|
||||
'--no-shrink',
|
||||
'--verbose',
|
||||
], workingDirectory: woringDirectory);
|
||||
print(result.stdout);
|
||||
|
||||
Reference in New Issue
Block a user