android / android/android-test
[Bazel] Python dependency on @google_apputils//:apputils not working
- Lingua principale
- Java
- Stelle
- 1.2k
- Fork
- 342
- Merge medio
- 11h 29m
- PR unite (30g)
- 2
Descrizione
### Description
I'm trying to start a `android_device` through Bazel, defined this way:
```
load("@rules_android//android:rules.bzl", "android_device")
android_device(
name = "pixel_api_23_x86",
cache = 64,
default_properties = "pixel.properties",
horizontal_resolution = 1080,
ram = 2048,
screen_density = 441,
system_image = "@androidsdk//:emulator_images_android_23_x86",
tags = ["requires-kvm"],
vertical_resolution = 1920,
vm_heap = 64,
)
```
With in my `WORKSPACE`:
```
android_sdk_repository(
name = "androidsdk",
)
http_archive(
name = "rules_android",
sha256 = "6461c1c5744442b394f46645957d6bd3420eb1b421908fe63caa03091b1b3655",
strip_prefix = "rules_android-0.1.1",
url = "https://github.com/bazelbuild/rules_android/archive/v0.1.1.tar.gz",
)
# ...
http_archive(
name = "android_test_support",
sha256 = "0c5d67ea781c25d9400394279a12eac3d75eda09cabe8ef73c0185575ec90e4d",
strip_prefix = "android-test-androidx-test-1.3.0",
url = "https://github.com/android/android-test/archive/androidx-test-1.3.0.tar.gz",
)
load("@android_test_support//:repo.bzl", "android_test_repositories")
android_test_repositories()
```
And in my `.bazelrc`, as Python 3 is the default on my OS (Archlinux):
```
build --host_force_python=PY2
test --host_force_python=PY2
```
I then try to start my device:
```
bazel run -s //java/fr/enoent/android/devices:pixel_api_23_x86 -- --action=start
INFO: Invocation ID: edb1e337-509d-495c-90be-80ee8e8c3af1
DEBUG: /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/external/rules_python/python/pip.bzl:61:10: DEPRECATED: the pip_repositories rule has been replaced with pip_install, please see rules_python 0.1 release notes
INFO: Analyzed target //java/fr/enoent/android/devices:pixel_api_23_x86 (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //java/fr/enoent/android/devices:pixel_api_23_x86 [action 'Creating Android image for //java/fr/enoent/android/devices:pixel_api_23_x86', configuration: c3c69cb4faf4425f09ab76fd33874f8875e3c84703bc9f472a65d1af99857697, execution platform: @local_config_platform//:host]
(cd /home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/execroot/fr_enoent && \
exec env - \
bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head '--action=boot' '--density=441' '--memory=2048' '--cache=64' '--vm_size=64' '--generate_output_dir=bazel-out/k8-fastbuild/bin/java/fr/enoent/android/devices/pixel_api_23_x86_images' '--skin=1080x1920' '--source_properties_file=external/androidsdk/system-images/android-23/default/x86/source.properties' '--system_images=external/androidsdk/system-images/android-23/default/x86/NOTICE.txt external/androidsdk/system-images/android-23/default/x86/advancedFeatures.ini external/androidsdk/system-images/android-23/default/x86/build.prop external/androidsdk/system-images/android-23/default/x86/kernel-qemu external/androidsdk/system-images/android-23/default/x86/kernel-ranchu external/androidsdk/system-images/android-23/default/x86/ramdisk.img external/androidsdk/system-images/android-23/default/x86/system.img external/androidsdk/system-images/android-23/default/x86/userdata.img' --flag_configured_android_tools '--adb=external/androidsdk/platform-tools/adb' '--emulator_x86=external/androidsdk/emulator/emulator' '--emulator_arm=external/androidsdk/emulator/emulator' '--adb_static=external/bazel_tools/tools/android/fail.sh' '--mksdcard=external/androidsdk/emulator/mksdcard' '--empty_snapshot_fs=bazel-out/host/bin/external/bazel_tools/tools/android/emulator/snapshots.img' '--bios_files=external/androidsdk/emulator/lib/pc-bios/bios-256k.bin,external/androidsdk/emulator/lib/pc-bios/bios.bin,external/androidsdk/emulator/lib/pc-bios/efi-e1000.rom,external/androidsdk/emulator/lib/pc-bios/efi-e1000e.rom,external/androidsdk/emulator/lib/pc-bios/efi-virtio.rom,external/androidsdk/emulator/lib/pc-bios/kvmvapic.bin,external/androidsdk/emulator/lib/pc-bios/linuxboot.bin,external/androidsdk/emulator/lib/pc-bios/linuxboot_dma.bin,external/androidsdk/emulator/lib/pc-bios/multiboot.bin,external/androidsdk/emulator/lib/pc-bios/vgabios-cirrus.bin,external/androidsdk/emulator/lib/pc-bios/vgabios-stdvga.bin,external/androidsdk/emulator/lib/pc-bios/vgabios-virtio.bin' --nocopy_system_images --single_image_file '--android_sdk_path=external/androidsdk' '--platform_apks=' '--default_properties_file=java/fr/enoent/android/devices/pixel.properties')
ERROR: /home/kernald/dev/monos/java/fr/enoent/android/devices/BUILD:3:15: Creating Android image for //java/fr/enoent/android/devices:pixel_api_23_x86 failed: (Exit 1): unified_launcher_head failed: error executing command bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head '--action=boot' '--density=441' '--memory=2048' '--cache=64' '--vm_size=64' ... (remaining 17 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox unified_launcher_head failed: error executing command bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head '--action=boot' '--density=441' '--memory=2048' '--cache=64' '--vm_size=64' ... (remaining 17 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
File "/home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/sandbox/linux-sandbox/2370/execroot/fr_enoent/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/unified_launcher.py", line 39, in
from tools.android.emulator import emulated_device
File "/home/kernald/.cache/bazel/_bazel_kernald/551cfa9086d3d42cb8d718a9a97333ef/sandbox/linux-sandbox/2370/execroot/fr_enoent/bazel-out/host/bin/external/android_test_support/tools/android/emulator/unified_launcher_head.runfiles/android_test_support/tools/android/emulator/emulated_device.py", line 55, in
from google.apputils import stopwatch
ImportError: No module named apputils
If you want to add certificates to the emulator, Please install MCrypt library using sudo apt-get install python-mcrypt .
Target //java/fr/enoent/android/devices:pixel_api_23_x86 failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.425s, Critical Path: 0.21s
INFO: 2 processes: 2 internal.
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully
```
What's interesting is that `unified_launcher_head` [does indeed have that missing dependency](https://github.com/android/android-test/blob/androidx-test-1.3.0/tools/android/emulator/BUILD.bazel#L121-L136). If I install locally `google-apputils`, I then get a failed import for `protobuf`. Everything then works fine (I mean the emulator is dying, but at least it starts...) if I install `protobuf` manually. Are Bazel users expected to install those dependencies manually?
### Steps to Reproduce
### Expected Results
The emulator should start
### Actual Results
The emulator fails to start because of missing Python dependencies
### AndroidX Test and Android OS Versions
1.3.0 (same with 1.4.0-alpha05)
### Link to a public git repo demonstrating the problem:
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da tools/android/emulator/BUILD.bazel, in particolare dalle dipendenze di unified_launcher_head intorno alle righe 121-136, poi esamina unified_launcher.py ed emulated_device.py. Riproduci il comando Bazel run e verifica se le dipendenze Python dichiarate sono disponibili nella sandbox. Il lavoro è completato quando l’avviatore dell’emulatore si avvia senza installare manualmente google-apputils o protobuf.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- android, python
- Ambito
- build-system, mobile-dev
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100