Commit c9644a49 authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

Read package ID and activity name from .apk for Gradle-based builds. (#8452)

The gradle build scripts can be configured to output different
application IDs for different build types, so we need to examine the
built .apk to figure out the name of the package and activity.

Re-landing this change, updated to only get information from the .apk
if it exists.

Since the tools create an AndroidApk instance early, even before we've
actually built an .apk, we have to create a new instance after building,
so we can start the right app/activity.

Fixes #8327.
parent ddaba899
......@@ -283,9 +283,6 @@ class AndroidDevice extends Device {
return new LaunchResult.failed();
}
printTrace("Stopping app '${package.name}' on $name.");
await stopApp(package);
if (!prebuiltApplication) {
printTrace('Building APK');
await buildApk(platform,
......@@ -294,8 +291,14 @@ class AndroidDevice extends Device {
kernelContent: kernelContent,
applicationNeedsRebuild: applicationNeedsRebuild
);
// Package has been built, so we can get the updated application ID and
// activity name from the .apk.
package = new AndroidApk.fromCurrentDirectory();
}
printTrace("Stopping app '${package.name}' on $name.");
await stopApp(package);
if (isLatestBuildInstalled(package)) {
printStatus('Latest build already installed.');
} else {
......
......@@ -82,6 +82,14 @@ class AndroidApk extends ApplicationPackage {
String apkPath;
if (isProjectUsingGradle()) {
if (fs.file(gradleAppOut).existsSync()) {
// Grab information from the .apk. The gradle build script might alter
// the application Id, so we need to look at what was actually built.
return new AndroidApk.fromApk(gradleAppOut);
}
// The .apk hasn't been built yet, so we work with what we have. The run
// command will grab a new AndroidApk after building, to get the updated
// IDs.
manifestPath = gradleManifestPath;
apkPath = gradleAppOut;
} else {
......
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