add printError messages and tool exit to android device (#31400)
This commit is contained in:
@@ -383,6 +383,10 @@ class AndroidDevice extends Device {
|
||||
// activity name from the .apk.
|
||||
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.");
|
||||
await stopApp(package);
|
||||
|
||||
@@ -166,8 +166,11 @@ class AndroidApk extends ApplicationPackage {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
final String manifestString = manifest.readAsStringSync();
|
||||
xml.XmlDocument document;
|
||||
@@ -186,8 +189,11 @@ class AndroidApk extends ApplicationPackage {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
final String packageId = manifests.first.getAttribute('package');
|
||||
|
||||
String launchActivity;
|
||||
@@ -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 AndroidApk(
|
||||
id: packageId,
|
||||
|
||||
Reference in New Issue
Block a user