From dd440d0c21bfd9bcc33a76937c63add95c5c6e27 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Wed, 16 Dec 2015 16:06:59 -0800 Subject: [PATCH] Fix `flutter apk` to work with resources I screwed up my last change, turns out the package command is sensitive about having all of its flags before args. Also made it possible to control the resources directory from the command line per the review comments in the previous change. @jason-simmons --- .../flutter_tools/lib/src/commands/apk.dart | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/apk.dart b/packages/flutter_tools/lib/src/commands/apk.dart index 11851374a38..6feb7fe37fe 100644 --- a/packages/flutter_tools/lib/src/commands/apk.dart +++ b/packages/flutter_tools/lib/src/commands/apk.dart @@ -19,6 +19,7 @@ import 'start.dart'; const String _kDefaultAndroidManifestPath = 'apk/AndroidManifest.xml'; const String _kDefaultOutputPath = 'build/app.apk'; +const String _kDefaultResourcesPath = 'apk/res'; const String _kKeystoreKeyName = "chromiumdebugkey"; const String _kKeystorePassword = "chromium"; @@ -74,11 +75,11 @@ class _ApkBuilder { '-A', assets.path, '-I', _androidJar.path, '-F', outputApk.path, - artifacts.path ]; - if (resources.existsSync()) { - packageArgs.addAll(['-S', resources.path]); + if (resources != null) { + packageArgs.addAll(['-S', resources.absolute.path]); } + packageArgs.add(artifacts.path); runCheckedSync(packageArgs); } @@ -115,6 +116,10 @@ class ApkCommand extends FlutterCommand { abbr: 'm', defaultsTo: _kDefaultAndroidManifestPath, help: 'Android manifest XML file.'); + argParser.addOption('resources', + abbr: 'r', + defaultsTo: _kDefaultResourcesPath, + help: 'Resources directory path.'); argParser.addOption('output-file', abbr: 'o', defaultsTo: _kDefaultOutputPath, @@ -159,13 +164,18 @@ class ApkCommand extends FlutterCommand { _ApkComponents components = new _ApkComponents(); components.androidSdk = new Directory(androidSdkPath); - components.manifest = new File(argResults['manifest']);; + components.manifest = new File(argResults['manifest']); components.icuData = new File(artifactPaths[0]); components.classesDex = new File(artifactPaths[1]); components.libSkyShell = new File(artifactPaths[2]); components.keystore = new File(artifactPaths[3]); - // TODO(eseidel): Should this be configurable from flutter.yaml? - components.resources = new Directory('apk/res'); + components.resources = new Directory(argResults['resources']); + + if (!components.resources.existsSync()) { + // TODO(eseidel): This level should be higher when path is manually set. + logging.info('Can not locate Resources: ${components.resources}, ignoring.'); + components.resources = null; + } if (!components.androidSdk.existsSync()) { logging.severe('Can not locate Android SDK: $androidSdkPath');