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 '../project.dart'; 12 13import 'android_sdk.dart'; 14import 'gradle.dart'; 15 16Future<void> buildApk({ 17 @required FlutterProject project, 18 @required String target, 19 @required AndroidBuildInfo androidBuildInfo, 20}) async { 21 if (!project.android.isUsingGradle) { 22 throwToolExit( 23 'The build process for Android has changed, and the current project configuration\n' 24 'is no longer valid. Please consult\n\n' 25 ' https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle\n\n' 26 'for details on how to upgrade the project.' 27 ); 28 } 29 30 // Validate that we can find an android sdk. 31 if (androidSdk == null) 32 throwToolExit('No Android SDK found. Try setting the ANDROID_SDK_ROOT environment variable.'); 33 34 await buildGradleProject( 35 project: project, 36 androidBuildInfo: androidBuildInfo, 37 target: target, 38 isBuildingBundle: false, 39 ); 40 androidSdk.reinitialize(); 41} 42