forked from qt-creator/qt-creator
Android: report am start errors in case process returns success
Somehow "am start" command can output to stderr even if the process
reports success, this can cause the activity launch to fail silently.
For example calling "am start -n package/activity --user 2" can fail
if the device has no user 2, however the process result will be success,
and the stderr will contain something like:
Error type 3
Error: Activity class {org.qtproject.example.scroll_example/
org.qtproject.qt.android.bindings.QtActivity} does not exist.
And the app won't start.
This concerns mostly extra am start args provided by the user, but not
sure if it might happen in other cases, so make sure to report the
stderr nonetheless.
Change-Id: I9317e118fcf4fe0c3ed83dcc53c1c00564c5148e
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -327,7 +327,7 @@ AndroidRunnerWorker::~AndroidRunnerWorker()
|
||||
}
|
||||
|
||||
bool AndroidRunnerWorker::runAdb(const QStringList &args, QString *stdOut,
|
||||
const QByteArray &writeData)
|
||||
QString *stdErr, const QByteArray &writeData)
|
||||
{
|
||||
QStringList adbArgs = selector() + args;
|
||||
SdkToolResult result = AndroidManager::runAdbCommand(adbArgs, writeData);
|
||||
@@ -335,6 +335,8 @@ bool AndroidRunnerWorker::runAdb(const QStringList &args, QString *stdOut,
|
||||
emit remoteErrorOutput(result.stdErr());
|
||||
if (stdOut)
|
||||
*stdOut = result.stdOut();
|
||||
if (stdErr)
|
||||
*stdErr = result.stdErr();
|
||||
return result.success();
|
||||
}
|
||||
|
||||
@@ -651,10 +653,17 @@ void AndroidRunnerWorker::asyncStartHelper()
|
||||
.toUtf8().toBase64());
|
||||
}
|
||||
|
||||
if (!runAdb(args)) {
|
||||
QString stdErr;
|
||||
const bool startResult = runAdb(args, nullptr, &stdErr);
|
||||
if (!startResult) {
|
||||
emit remoteProcessFinished(tr("Failed to start the activity."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stdErr.isEmpty()) {
|
||||
emit remoteErrorOutput(tr("Activity Manager threw the error: %1").arg(stdErr));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir,
|
||||
|
||||
Reference in New Issue
Block a user