apk.dart 1.18 KB
Newer Older
1 2 3 4 5 6
// Copyright 2015 The Chromium 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 'dart:async';

7 8
import 'package:meta/meta.dart';

9 10
import '../base/common.dart';
import '../build_info.dart';
11 12
import '../project.dart';

13 14 15
import 'android_sdk.dart';
import 'gradle.dart';

16
Future<void> buildApk({
17 18
  @required FlutterProject project,
  @required String target,
19
  BuildInfo buildInfo = BuildInfo.debug,
20
}) async {
21
  if (!project.android.isUsingGradle) {
22 23 24 25 26 27 28 29 30 31
    throwToolExit(
        'The build process for Android has changed, and the current project configuration\n'
            'is no longer valid. Please consult\n\n'
            '  https://github.com/flutter/flutter/wiki/Upgrading-Flutter-projects-to-build-with-gradle\n\n'
            'for details on how to upgrade the project.'
    );
  }

  // Validate that we can find an android sdk.
  if (androidSdk == null)
32
    throwToolExit('No Android SDK found. Try setting the ANDROID_SDK_ROOT environment variable.');
33

34
  await buildGradleProject(
35 36 37
    project: project,
    buildInfo: buildInfo,
    target: target,
38
    isBuildingBundle: false,
39
  );
40
  androidSdk.reinitialize();
41
}