apk.dart 1.2 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 17 18
Future<void> buildApk({
  @required FlutterProject project,
  @required String target,
19
  @required AndroidBuildInfo androidBuildInfo,
20 21 22
}) async {
  if (!project.android.isUsingGradle) {
    throwToolExit(
23
        'The build process for Android has changed, and the current project configuration\n'
24 25 26
            '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.'
27 28 29
    );
  }

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

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