diff --git a/examples/fitness/apk/AndroidManifest.xml b/examples/fitness/apk/AndroidManifest.xml
index 2d36384715..69323d5817 100644
--- a/examples/fitness/apk/AndroidManifest.xml
+++ b/examples/fitness/apk/AndroidManifest.xml
@@ -13,12 +13,12 @@
-
-
+
-
+
diff --git a/examples/fitness/apk/src/org/domokit/fitness/FitnessApplication.java b/examples/fitness/apk/src/org/domokit/fitness/FitnessApplication.java
deleted file mode 100644
index ab3edb3228..0000000000
--- a/examples/fitness/apk/src/org/domokit/fitness/FitnessApplication.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-package org.domokit.fitness;
-
-import android.content.Context;
-
-import org.chromium.mojo.system.Core;
-import org.chromium.mojo.system.MessagePipeHandle;
-import org.chromium.mojom.gcm.GcmService;
-import org.domokit.gcm.RegistrationIntentService;
-import org.domokit.sky.shell.ServiceFactory;
-import org.domokit.sky.shell.ServiceRegistry;
-import org.domokit.sky.shell.SkyApplication;
-
-/**
- * Sky implementation of {@link android.app.Application}, managing application-level global
- * state and initializations.
- */
-public class FitnessApplication extends SkyApplication {
- /**
- * Override this function to register more services.
- */
- protected void onServiceRegistryAvailable(ServiceRegistry registry) {
- super.onServiceRegistryAvailable(registry);
-
- registry.register(GcmService.MANAGER.getName(), new ServiceFactory() {
- @Override
- public void connectToService(Context context, Core core, MessagePipeHandle pipe) {
- GcmService.MANAGER.bind(
- new RegistrationIntentService.MojoService(context), pipe);
- }
- });
- }
-}
diff --git a/examples/fitness/flutter.yaml b/examples/fitness/flutter.yaml
index 942a5de5ed..f5325d2a4e 100644
--- a/examples/fitness/flutter.yaml
+++ b/examples/fitness/flutter.yaml
@@ -13,3 +13,5 @@ material-design-icons:
- name: navigation/close
- name: navigation/menu
- name: navigation/more_vert
+services:
+ - gcm
diff --git a/examples/fitness/lib/main.dart b/examples/fitness/lib/main.dart
index 311bfc7139..c44d54aa8c 100644
--- a/examples/fitness/lib/main.dart
+++ b/examples/fitness/lib/main.dart
@@ -175,5 +175,6 @@ initGcm() async {
}
main() {
+ initGcm();
runApp(new FitnessApp());
}
diff --git a/packages/flutter/pubspec.yaml b/packages/flutter/pubspec.yaml
index cee899cbb9..afc4e9b18d 100644
--- a/packages/flutter/pubspec.yaml
+++ b/packages/flutter/pubspec.yaml
@@ -8,8 +8,8 @@ dependencies:
collection: '>=1.1.3 <2.0.0'
intl: '>=0.12.4+2 <0.13.0'
material_design_icons: '>=0.0.3 <0.1.0'
- sky_engine: 0.0.85
- sky_services: 0.0.85
+ sky_engine: 0.0.86
+ sky_services: 0.0.86
vector_math: '>=1.4.5 <2.0.0'
quiver: '>=0.21.4 <0.22.0'
diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart
index e6a5f4f0d7..04b0d491fd 100644
--- a/packages/flutter_tools/lib/src/artifacts.dart
+++ b/packages/flutter_tools/lib/src/artifacts.dart
@@ -47,7 +47,7 @@ enum ArtifactType {
snapshot,
shell,
mojo,
- androidClassesDex,
+ androidClassesJar,
androidIcuData,
androidKeystore,
androidLibSkyShell,
@@ -124,8 +124,8 @@ class ArtifactStore {
),
const Artifact._(
name: 'Compiled Java code',
- fileName: 'classes.dex',
- type: ArtifactType.androidClassesDex,
+ fileName: 'classes.dex.jar',
+ type: ArtifactType.androidClassesJar,
targetPlatform: TargetPlatform.android
),
const Artifact._(
@@ -219,14 +219,12 @@ class ArtifactStore {
);
}
- /// Download the artifacts.zip archive for the given platform from GCS
- /// and extract it to the local cache.
- static Future _doDownloadArtifactsFromZip(String platform) async {
- String url = getCloudStorageBaseUrl(platform) + 'artifacts.zip';
+ /// Download a file from the given URL and return the bytes.
+ static Future> _downloadFile(Uri url) async {
logging.info('Downloading $url.');
HttpClient httpClient = new HttpClient();
- HttpClientRequest request = await httpClient.getUrl(Uri.parse(url));
+ HttpClientRequest request = await httpClient.getUrl(url);
HttpClientResponse response = await request.close();
logging.fine('Received response statusCode=${response.statusCode}');
if (response.statusCode != 200)
@@ -237,13 +235,29 @@ class ArtifactStore {
responseBody.add(chunk);
}
- Archive archive = new ZipDecoder().decodeBytes(responseBody.takeBytes());
+ return responseBody.takeBytes();
+ }
+
+ /// Download a file from the given url and write it to the cache.
+ static Future _downloadFileToCache(Uri url, File cachedFile) async {
+ if (!cachedFile.parent.existsSync())
+ cachedFile.parent.createSync(recursive: true);
+
+ List fileBytes = await _downloadFile(url);
+ cachedFile.writeAsBytesSync(fileBytes, flush: true);
+ }
+
+ /// Download the artifacts.zip archive for the given platform from GCS
+ /// and extract it to the local cache.
+ static Future _doDownloadArtifactsFromZip(String platform) async {
+ String url = getCloudStorageBaseUrl(platform) + 'artifacts.zip';
+ List zipBytes = await _downloadFile(Uri.parse(url));
+
+ Archive archive = new ZipDecoder().decodeBytes(zipBytes);
Directory cacheDir = _getCacheDirForPlatform(platform);
for (ArchiveFile archiveFile in archive) {
File cacheFile = new File(path.join(cacheDir.path, archiveFile.name));
- IOSink sink = cacheFile.openWrite();
- sink.add(archiveFile.content);
- await sink.close();
+ cacheFile.writeAsBytesSync(archiveFile.content, flush: true);
}
for (Artifact artifact in knownArtifacts) {
@@ -306,6 +320,23 @@ class ArtifactStore {
return cachedFile.path;
}
+ static Future getThirdPartyFile(String urlStr, String cacheSubdir) async {
+ Uri url = Uri.parse(urlStr);
+ Directory baseDir = _getBaseCacheDir();
+ Directory cacheDir = new Directory(path.join(
+ baseDir.path, 'third_party', cacheSubdir));
+ File cachedFile = new File(
+ path.join(cacheDir.path, url.pathSegments[url.pathSegments.length-1]));
+ if (!cachedFile.existsSync()) {
+ await _downloadFileToCache(url, cachedFile);
+ if (!cachedFile.existsSync()) {
+ logging.severe('Unable to fetch third-party artifact: $url');
+ throw new ProcessExit(2);
+ }
+ }
+ return cachedFile.path;
+ }
+
static void clear() {
Directory cacheDir = _getBaseCacheDir();
logging.fine('Clearing cache directory ${cacheDir.path}');
diff --git a/packages/flutter_tools/lib/src/commands/apk.dart b/packages/flutter_tools/lib/src/commands/apk.dart
index b9bfe124cf..c894d0bea8 100644
--- a/packages/flutter_tools/lib/src/commands/apk.dart
+++ b/packages/flutter_tools/lib/src/commands/apk.dart
@@ -3,9 +3,11 @@
// found in the LICENSE file.
import 'dart:async';
+import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as path;
+import 'package:yaml/yaml.dart';
import '../artifacts.dart';
import '../base/file_system.dart';
@@ -21,6 +23,9 @@ const String _kDefaultAndroidManifestPath = 'apk/AndroidManifest.xml';
const String _kDefaultOutputPath = 'build/app.apk';
const String _kDefaultResourcesPath = 'apk/res';
+const String _kFlutterManifestPath = 'flutter.yaml';
+const String _kPubspecYamlPath = 'pubspec.yaml';
+
// Alias of the key provided in the Chromium debug keystore
const String _kDebugKeystoreKeyAlias = "chromiumdebugkey";
@@ -56,6 +61,7 @@ class _ApkBuilder {
File _androidJar;
File _aapt;
+ File _dx;
File _zipalign;
String _jarsigner;
@@ -64,12 +70,25 @@ class _ApkBuilder {
String buildTools = '$androidSdk/build-tools/$_kBuildToolsVersion';
_aapt = new File('$buildTools/aapt');
+ _dx = new File('$buildTools/dx');
_zipalign = new File('$buildTools/zipalign');
_jarsigner = 'jarsigner';
}
bool checkSdkPath() {
- return (_androidJar.existsSync() && _aapt.existsSync() && _zipalign.existsSync());
+ return (_androidJar.existsSync() && _aapt.existsSync() && _dx.existsSync() && _zipalign.existsSync());
+ }
+
+ void compileClassesDex(File classesDex, List jars) {
+ List packageArgs = [_dx.path,
+ '--dex',
+ '--force-jumbo',
+ '--output', classesDex.path
+ ];
+
+ packageArgs.addAll(jars.map((File f) => f.path));
+
+ runCheckedSync(packageArgs);
}
void package(File outputApk, File androidManifest, Directory assets, Directory artifacts, Directory resources) {
@@ -106,12 +125,21 @@ class _ApkComponents {
Directory androidSdk;
File manifest;
File icuData;
- File classesDex;
+ List jars;
+ List