Unverified Commit 9e51e13e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

add printError messages and tool exit to android device (#31400)

parent 2dc66f0a
...@@ -383,6 +383,10 @@ class AndroidDevice extends Device { ...@@ -383,6 +383,10 @@ class AndroidDevice extends Device {
// activity name from the .apk. // activity name from the .apk.
package = await AndroidApk.fromAndroidProject(project.android); package = await AndroidApk.fromAndroidProject(project.android);
} }
// There was a failure parsing the android project information.
if (package == null) {
throwToolExit('Problem building Android application: see above error(s).');
}
printTrace("Stopping app '${package.name}' on $name."); printTrace("Stopping app '${package.name}' on $name.");
await stopApp(package); await stopApp(package);
......
...@@ -166,8 +166,11 @@ class AndroidApk extends ApplicationPackage { ...@@ -166,8 +166,11 @@ class AndroidApk extends ApplicationPackage {
final File manifest = androidProject.appManifestFile; final File manifest = androidProject.appManifestFile;
if (!manifest.existsSync()) if (!manifest.existsSync()) {
printError('AndroidManifest.xml could not be found.');
printError('Please check ${manifest.path} for errors.');
return null; return null;
}
final String manifestString = manifest.readAsStringSync(); final String manifestString = manifest.readAsStringSync();
xml.XmlDocument document; xml.XmlDocument document;
...@@ -186,8 +189,11 @@ class AndroidApk extends ApplicationPackage { ...@@ -186,8 +189,11 @@ class AndroidApk extends ApplicationPackage {
} }
final Iterable<xml.XmlElement> manifests = document.findElements('manifest'); final Iterable<xml.XmlElement> manifests = document.findElements('manifest');
if (manifests.isEmpty) if (manifests.isEmpty) {
printError('AndroidManifest.xml has no manifest element.');
printError('Please check ${manifest.path} for errors.');
return null; return null;
}
final String packageId = manifests.first.getAttribute('package'); final String packageId = manifests.first.getAttribute('package');
String launchActivity; String launchActivity;
...@@ -220,8 +226,11 @@ class AndroidApk extends ApplicationPackage { ...@@ -220,8 +226,11 @@ class AndroidApk extends ApplicationPackage {
} }
} }
if (packageId == null || launchActivity == null) if (packageId == null || launchActivity == null) {
printError('package identifier or launch activity not found.');
printError('Please check ${manifest.path} for errors.');
return null; return null;
}
return AndroidApk( return AndroidApk(
id: packageId, id: packageId,
......
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