Cannot support non-standard location for `.android` directory
- Dominant language
- Python
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 40
Description
### Describe the bug
The default location for the Android SDK's `.android` directory is `$HOME/.android` but it can be an arbitrary directory via `ANDROID_USER_HOME`. When Briefcase creates an AVD, it tries to modify its configuration afterwards; this fails because it assumes the AVD is located within `$HOME/.android`. More generally, enumerating the list of AVDs assumes this location as well.
### Steps to reproduce
Run `ANDROID_USER_HOME=/tmp/android briefcase run android` and create a new emulator.
```
❯ ANDROID_USER_HOME=/tmp/android briefcase run android -vv
Using JDK at /home/russell/.cache/briefcase/tools/java17
Using Android SDK at /home/russell/.cache/briefcase/tools/android_sdk
Android emulator is already installed.
>>> Running Command:
>>> /home/russell/.cache/briefcase/tools/android_sdk/platform-tools/adb devices -l
>>> Working Directory:
>>> /home/russell/tmp/beeware/helloworld
>>> Command Output:
>>> List of devices attached
>>>
>>> Return code: 0
>>> Running Command:
>>> /home/russell/.cache/briefcase/tools/android_sdk/emulator/emulator -list-avds
>>> Working Directory:
>>> /home/russell/tmp/beeware/helloworld
>>> Command Output:
>>> beePhone
>>> Return code: 0
Select device:
1) @beePhone (emulator)
2) Create a new Android emulator
> 2
>>> Running Command:
>>> /home/russell/.cache/briefcase/tools/android_sdk/emulator/emulator -list-avds
>>> Working Directory:
>>> /home/russell/tmp/beeware/helloworld
>>> Command Output:
>>> beePhone
>>> Return code: 0
You need to select a name for your new emulator. This is an identifier that
can be used to start the emulator in future. It should follow the same naming
conventions as a Python package (i.e., it may only contain letters, numbers,
hyphens and underscores). If you don't provide a name, Briefcase will use the
a default name 'beePhone2'.
Emulator name [beePhone2]:
Device skin 'pixel_7_pro' already exists.
>>> Running Command:
>>> /home/russell/.cache/briefcase/tools/android_sdk/cmdline-tools/9.0/bin/avdmanager --verbose create avd --name beePhone2 --abi x86_64 --package 'system-images;android-31;default;x86_64' --device pixel
>>> Working Directory:
>>> /home/russell/tmp/beeware/helloworld
>>> Environment Overrides:
>>> ANDROID_HOME=/home/russell/.cache/briefcase/tools/android_sdk
>>> ANDROID_SDK_ROOT=/home/russell/.cache/briefcase/tools/android_sdk
>>> JAVA_HOME=/home/russell/.cache/briefcase/tools/java17
>>> Command Output:
>>> Loading local repository...
>>> [========= ] 25% Loading local repository...
>>> [========= ] 25% Fetch remote repository...
>>> [=======================================] 100% Fetch remote repository...
>>> Return code: 0
Creating Android emulator beePhone2... done
Adding extra device configuration... errored
Unable to read configuration of AVD @beePhone2
```
### Expected behavior
Briefcase respects `ANDROID_USER_HOME` or similar.
### Screenshots
_No response_
### Environment
- Operating System: pop os 22.04
- Python version: 3.10
- Software versions:
- Briefcase: `0.3.18.dev72+ge141754e`
### Logs
[briefcase.2024_02_24-16_41_28.run.log](https://github.com/beeware/briefcase/files/14394489/briefcase.2024_02_24-16_41_28.run.log)
### Additional context
_No response_
Contributor guide
Research direction
Reproduce the issue with ANDROID_USER_HOME=/tmp/android briefcase run android and trace Android AVD creation and enumeration. Check the paths used after avdmanager creates an emulator and when listing AVDs; done means both operations respect the configured directory and the reported configuration can be read successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, python
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100