Skip to content

Improve Android "install failed" messages - #2949

Open
moondial-pal wants to merge 4 commits into
beeware:mainfrom
moondial-pal:install-failed-messages
Open

Improve Android "install failed" messages#2949
moondial-pal wants to merge 4 commits into
beeware:mainfrom
moondial-pal:install-failed-messages

Conversation

@moondial-pal

Copy link
Copy Markdown
Contributor

The two known failure markers UPDATE_INCOMPATIBLE and VERSION_DOWNGRADE now present the user with an informative error message indicating the probable cause and include a suggested route for resolution.

Previously, both failures produced the same generic 'Unable to install APK' message, giving users no indication of what went wrong or how to fix it.

Refs #1362

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Assisted-by: Claude Sonnet

@moondial-pal

Copy link
Copy Markdown
Contributor Author

INSTALL_FAILED_VERSION_DOWNGRADE

image

INSTALL_FAILED_UPDATE_INCOMPATIBLE

image

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Looking for feedback on the error messages. Happy to change them if needed.

Also, since both messages suggest uninstalling as the remedy, should there be a note warning that this wipes the app's data? @mhsmith raised the same concern back in the original thread, just in the context of an automatic uninstall/reinstall flow (#1362 (comment)), but it seems just as relevant here since someone could copy-paste the command without realizing the consequence.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Another note I'd like to mention is the adb command in these messages may not resolve if it's not on the user's PATH, still working on that fix.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Updated the error message to use Briefcase's managed adb path instead of assuming adb is already on the user's PATH.
It is long, but can be copied then pasted.
Running that to uninstall, then running Briefcase run android again will install cleanly.

@freakboy3742 or @mhsmith whenever you get a chance, this is ready for review.

@mhsmith
mhsmith self-requested a review July 29, 2026 20:40
@mhsmith mhsmith changed the title Install failed messages Improve Android "install failed" messages Jul 29, 2026
@freakboy3742

Copy link
Copy Markdown
Member

@moondial-pal Apologies for the delay in reviewing this - we should be able to get to this in the next couple of days.

computer). To resolve this, run the following command to uninstall the
existing app, then try again:

$ "{self.tools.android_sdk.adb_path}" -s {self.device} """

@mhsmith mhsmith Jul 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows users might not recognize "$" as a prompt, and think it's part of the command line. Let's just have no prompt at all.

Suggested change
$ "{self.tools.android_sdk.adb_path}" -s {self.device} """
"{self.tools.android_sdk.adb_path}" -s {self.device} """

@mhsmith mhsmith Jul 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this repeated command line should be factored out into a variable. The variable can also include the "To resolve this" sentence, along with the data loss warning you suggested.

Unable to install APK {apk_path} on {self.device}

The app currently installed on the device was signed with a different key
than this APK (often because it was previously installed from a different

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to focus on the user's current situation rather than making generalizations.

Suggested change
than this APK (often because it was previously installed from a different
than this APK (maybe because it was installed from a different

Comment on lines +1496 to +1498
raise BriefcaseCommandError(
f"""\
Unable to install APK {apk_path} on {self.device}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We recently added some helper methods to avoid this kind of confusing indentation (#2559). However, in this case we don't need the asterisk box to call attention to the message, because it's the last thing printed before Briefcase exits.

So I think we should make _dedent_and_wrap a public function, and make its width argument default to 80 like the other functions. Then it can be used here to wrap the message, similarly to this example. It looks like it already avoids wrapping further-indented lines, such as the command line here.

) from e
else:
raise BriefcaseCommandError(
f"Unable to install APK {apk_path} on {self.device}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3 copies of this message should be factored out into a variable.


with pytest.raises(BriefcaseCommandError) as exc_info:
adb.install_apk("example.apk", "com.example.helloworld")
assert "uninstall com.example.helloworld" in str(exc_info.value)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to include the full error text, but we should at least include enough words to check that the two different errors produce two different messages.

@mhsmith

mhsmith commented Jul 30, 2026

Copy link
Copy Markdown
Member

should there be a note warning that this wipes the app's data? @mhsmith raised the same concern back in the original thread, just in the context of an automatic uninstall/reinstall flow (#1362 (comment)), but it seems just as relevant here since someone could copy-paste the command without realizing the consequence.

Yes, that would be a good idea.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Thanks @mhsmith I'll get to work cleaning this up and addressing the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants