beeware / beeware/briefcase

Better accomodate installing APK when existing app cannot be replaced

Open
#1,362 6 comments 1 reaction 0 assignees View on GitHub
android bug
Dominant language
Python
Stars
3.3k
Forks
549
Avg merge
1d 4h
Merged PRs (30d)
40

Description

### 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](https://github.com/beeware/briefcase/files/12053969/briefcase.2023_07_14-17_02_12.run.log)

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the Android APK installation workflow that runs the shown adb install -r command, and reproduce the signature-mismatch failure with an existing app installed from another identity. Trace how the nonzero adb result is reported. Done means the workflow either falls back to uninstalling and reinstalling, or gives the user clear information about the replacement failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, python
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.