Unverified Commit e61ab4a8 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Copy APK into a known location, so it can be easily discovered (#53718)

parent b6423e45
......@@ -80,8 +80,7 @@ Future<void> main() async {
'build',
'app',
'outputs',
'apk',
'release',
'flutter-apk',
'app-release.apk',
));
......@@ -118,8 +117,7 @@ Future<void> main() async {
'build',
'app',
'outputs',
'apk',
'debug',
'flutter-apk',
'app-debug.apk',
));
......
......@@ -77,8 +77,7 @@ Future<void> main() async {
'build',
'app',
'outputs',
'apk',
'release',
'flutter-apk',
'app-release.apk',
));
......@@ -116,8 +115,7 @@ Future<void> main() async {
'build',
'app',
'outputs',
'apk',
'debug',
'flutter-apk',
'app-debug.apk',
));
......
......@@ -84,8 +84,7 @@ Future<void> main() async {
'build',
'app',
'outputs',
'apk',
'release',
'flutter-apk',
'app-release.apk',
));
......@@ -118,8 +117,7 @@ Future<void> main() async {
'build',
'app',
'outputs',
'apk',
'debug',
'flutter-apk',
'app-debug.apk',
));
......
......@@ -332,10 +332,10 @@ class FlutterPluginProject {
String get rootPath => path.join(parent.path, name);
String get examplePath => path.join(rootPath, 'example');
String get exampleAndroidPath => path.join(examplePath, 'android');
String get debugApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'apk', 'debug', 'app-debug.apk');
String get releaseApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'apk', 'release', 'app-release.apk');
String get releaseArmApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'apk', 'release', 'app-armeabi-v7a-release.apk');
String get releaseArm64ApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'apk', 'release', 'app-arm64-v8a-release.apk');
String get debugApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-debug.apk');
String get releaseApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-release.apk');
String get releaseArmApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk','app-armeabi-v7a-release.apk');
String get releaseArm64ApkPath => path.join(examplePath, 'build', 'app', 'outputs', 'flutter-apk', 'app-arm64-v8a-release.apk');
String get releaseBundlePath => path.join(examplePath, 'build', 'app', 'outputs', 'bundle', 'release', 'app.aab');
Future<void> runGradleTask(String task, {List<String> options}) async {
......
......@@ -757,7 +757,49 @@ class FlutterPlugin implements Plugin<Project> {
}
}
if (project.android.hasProperty("applicationVariants")) {
project.android.applicationVariants.all addFlutterDeps
project.android.applicationVariants.all { variant ->
addFlutterDeps(variant)
// Copy the output APKs into a known location, so `flutter run` or `flutter build apk`
// can discover them. By default, this is `<app-dir>/build/app/outputs/flutter-apk/<filename>.apk`.
//
// The filename consists of `app<-abi>?<-flavor-name>?-<build-mode>.apk`.
// Where:
// * `abi` can be `armeabi-v7a|arm64-v8a|x86|x86_64` only if the flag `split-per-abi` is set.
// * `flavor-name` is the flavor used to build the app in lower case if the assemble task is called.
// * `build-mode` can be `release|debug|profile`.
variant.outputs.all { output ->
// `assemble` became `assembleProvider` in AGP 3.3.0.
def assembleTask = variant.hasProperty("assembleProvider")
? variant.assembleProvider.get()
: variant.assemble
assembleTask.doLast {
// `packageApplication` became `packageApplicationProvider` in AGP 3.3.0.
def outputDirectory = variant.hasProperty("packageApplicationProvider")
? variant.packageApplicationProvider.get().outputDirectory
: variant.packageApplication.outputDirectory
// `outputDirectory` is a `DirectoryProperty` in AGP 4.1.
String outputDirectoryStr = outputDirectory.metaClass.respondsTo(outputDirectory, "get")
? outputDirectory.get()
: outputDirectory
String filename = "app"
String abi = output.getFilter(OutputFile.ABI)
if (abi != null && !abi.isEmpty()) {
filename += "-${abi}"
}
if (variant.flavorName != null && !variant.flavorName.isEmpty()) {
filename += "-${variant.flavorName.toLowerCase()}"
}
filename += "-${buildModeFor(variant.buildType)}"
project.copy {
from new File("$outputDirectoryStr/${output.outputFileName}")
into new File("${project.buildDir}/outputs/flutter-apk");
rename {
return "${filename}.apk"
}
}
}
}
}
} else {
project.android.libraryVariants.all addFlutterDeps
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment