From 80ef81422de79f3294e228af39a92608b139c2b6 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Tue, 3 May 2016 13:32:35 -0700 Subject: [PATCH] Support for putting assets in android/assets folder (like ios/Resources) --- .../flutter_tools/lib/src/commands/build_apk.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/flutter_tools/lib/src/commands/build_apk.dart b/packages/flutter_tools/lib/src/commands/build_apk.dart index f5fa04ec75..cf9bc82102 100644 --- a/packages/flutter_tools/lib/src/commands/build_apk.dart +++ b/packages/flutter_tools/lib/src/commands/build_apk.dart @@ -26,6 +26,7 @@ export '../android/android_device.dart' show AndroidDevice; const String _kDefaultAndroidManifestPath = 'android/AndroidManifest.xml'; const String _kDefaultOutputPath = 'build/app.apk'; const String _kDefaultResourcesPath = 'android/res'; +const String _kDefaultAssetsPath = 'android/assets'; const String _kFlutterManifestPath = 'flutter.yaml'; const String _kPackagesStatusPath = '.packages'; @@ -226,6 +227,16 @@ class BuildApkCommand extends FlutterCommand { extraFiles[keyValue.first] = new File(keyValue.last); } + if (FileSystemEntity.isDirectorySync(_kDefaultAssetsPath)) { + Directory assetsDir = new Directory(_kDefaultAssetsPath); + for (FileSystemEntity entity in assetsDir.listSync(recursive: true)) { + if (entity is File) { + String targetPath = entity.path.substring(assetsDir.path.length); + extraFiles["assets/$targetPath"] = entity; + } + }; + } + // TODO(devoncarew): This command should take an arg for the output type (arm / x64). return await buildAndroid(