Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better accomodate installing APK on physical device when existing app cannot be replaced #1362

Open
rmartin16 opened this issue Jul 14, 2023 · 4 comments
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.

Comments

@rmartin16
Copy link
Member

rmartin16 commented Jul 14, 2023

Describe the bug

The current APK install process can error if an existing version of the app cannot be replaced. For me, this happened because the existing app on the device was installed from a different computer.

[helloworld] Starting app on SM G960U (5759363737573398) (device ID 5759363737573398)

[helloworld] Installing app...

>>> Running Command:
>>>     /home/russell/.cache/briefcase/tools/android_sdk/platform-tools/adb -s 5759363737573398 shell am force-stop com.example.helloworld
>>> Working Directory:
>>>     /home/russell/tmp/beeware/helloworld
>>> Return code: 0
Stopping old versions of the app... done

>>> Running Command:
>>>     /home/russell/.cache/briefcase/tools/android_sdk/platform-tools/adb -s 5759363737573398 install -r /home/russell/tmp/beeware/helloworld/build/helloworld/android/gradle/app/build/outputs/apk/debug/app-debug.apk
>>> Working Directory:
>>>     /home/russell/tmp/beeware/helloworld
>>> Command Output:
>>>     adb: failed to install /home/russell/tmp/beeware/helloworld/build/helloworld/android/gradle/app/build/outputs/apk/debug/app-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example.helloworld signatures do not match previously installed version; ignoring!]
>>>     Performing Streamed Install
>>> Return code: 1
Installing new app version...

Unable to install APK /home/russell/tmp/beeware/helloworld/build/helloworld/android/gradle/app/build/outputs/apk/debug/app-debug.apk on 5759363737573398

Steps to reproduce

  1. Install an APK on a physical device
  2. Attempt to install APK from a different machine or using a different identity

Expected behavior

Fallback to an uninstall and install workflow or at least provide better information to the user about what's wrong.

A simple remedy is ~/.cache/briefcase/tools/android_sdk/platform-tools/adb uninstall "com.example.helloworld"

Screenshots

No response

Environment

  • Operating System: debian 11
  • Python version: 3.10.6
  • Software versions:
    • Briefcase: 0.3.16.dev9+gb6057a0d

Logs

briefcase.2023_07_14-17_02_12.run.log

Additional context

No response

@rmartin16 rmartin16 added bug A crash or error in behavior. android The issue relates to Android mobile support. labels Jul 14, 2023
@mhsmith
Copy link
Member

mhsmith commented Jul 15, 2023

Fallback to an uninstall and install workflow or at least provide better information to the user about what's wrong.

I think the message is already clear enough, but falling back to a separate uninstall and install would still be useful. However, I think we should ask for confirmation first, as Android Studio does, with a warning that uninstalling the existing app will wipe out all of its data.

A similar situation could happen with the INSTALL_FAILED_VERSION_DOWNGRADE error.

@mhsmith
Copy link
Member

mhsmith commented Jul 24, 2023

I think the message is already clear enough

Actually, as we've just found out from a user on Discord, the message is not displayed in non-verbose mode. All Briefcase displays in the console is:

Installing new app version...

Unable to install APK

[General discusssion moved to:]

@freakboy3742
Copy link
Member

freakboy3742 commented Jul 26, 2023

[Moved to #1907]

@freakboy3742
Copy link
Member

freakboy3742 commented Oct 7, 2023

I think the message is already clear enough

Yes, the subprocess output hints at the cause; but it also says that the problem was "ignored" - which... it clearly isn't (at least, not in a way that makes any sense to a Briefcase user).

I'd suggest that we should inspect the output for the INSTALL_FAILED_* marker, and convert that into a more helpful error message if it is detected. If we're able to get a comprehensive list of those failure markers, that would be great; but if not, starting with the 2 we know about an expanding the list as they're reported would also be a significant improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

3 participants