1// Copyright 2015 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5import 'dart:async'; 6 7import 'package:meta/meta.dart'; 8 9import '../base/common.dart'; 10import '../build_info.dart'; 11import '../globals.dart'; 12import '../project.dart'; 13 14import 'android_sdk.dart'; 15import 'gradle.dart'; 16 17Future<void> buildAppBundle({ 18 @required FlutterProject project, 19 @required String target, 20 @required AndroidBuildInfo androidBuildInfo, 21}) async { 22 if (!project.android.isUsingGradle) { 23 throwToolExit( 24 'The build process for Android has changed, and the current project configuration\n' 25 'is no longer valid. Please consult\n\n' 26 'https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle\n\n' 27 'for details on how to upgrade the project.' 28 ); 29 } 30 31 // Validate that we can find an android sdk. 32 if (androidSdk == null) 33 throwToolExit('No Android SDK found. Try setting the ANDROID_HOME environment variable.'); 34 35 final List<String> validationResult = androidSdk.validateSdkWellFormed(); 36 if (validationResult.isNotEmpty) { 37 for (String message in validationResult) { 38 printError(message, wrap: false); 39 } 40 throwToolExit('Try re-installing or updating your Android SDK.'); 41 } 42 43 return buildGradleProject( 44 project: project, 45 androidBuildInfo: androidBuildInfo, 46 target: target, 47 isBuildingBundle: true, 48 ); 49} 50