Closed quintus0505 closed 1 year ago
Hi @quintus0505,
Sorry for the delay, things have been really hectic here.
As you may have seen from issue #116 (link), our pip
package is really old. The first error you got was because of that because Python 3.8 doesn't have built-in annotations for example. We didn't have enough time yet to update the pip package... sorry.
As for your second error, the -adb-path
flag was introduced in the emulator sometime last year to ensure that it uses the same version that AndroidEnv uses so that there's no problem with protocol differences. It shouldn't have anything to do with the gRPC connection. Are you running an up-to-date version of the Emulator? And is this reproducible?
Thanks
Hi! Thank you for your reply.
Currently, I am using Flamingo | 2022.2.1 for Android Studio. I haven't used Android Studio before, so I created the emulator following your instructions https://github.com/deepmind/android_env/blob/main/docs/emulator_guide.md, and I was stuck by the adb-path.
I also tried another AVD, with the identical Pixel 2 but API Level equals 33 (Tiramisu), but I was still stuck by adb-path.
If the emulator version cause the problem, can you provide me with the recommended setting?
Thanks!
Hi,
The -adb-path
flag was submitted on Sep 9th 2022: https://android-review.googlesource.com/2210903. If the emulator version is older than that, you would get an error when booting complaining that the flag doesn't exist. Since you're not getting that, I'm quite confident that the flag is not the problem.
Can you check if the port 8554
is free? Another thing you can try is using another free port by overriding the grpc_port
argument by passing a value in the loader.
Is this all the logs that you have? Maybe you can put a few print statements when booting the emulator. If you start the emulator from Android Studio, does it work fine?
We don't really have a "recommended" setting. Internally we run different emulator versions from various API levels.
Oh, here is the full log:
(android_py) quintus@quintus-omen-22:~/Aalto/android_env/examples$ python run_random_agent.py --avd_name='my_avd_keyboard_2' --android_avd_home=/home/quintus/.android/avd --android_sdk_root=/home/quintus/Android/Sdk --emu
lator_path=/home/quintus/Android/Sdk/emulator/emulator --adb_path=/home/quintus/Android/Sdk/platform-tools/adb --num_steps=1000 --task_path=/home/quintus/Aalto/android_env/tasks/apple_flinger/apple_flinger_M_1_1.textproto
I0425 23:41:22.628003 140469032242048 adb_controller.py:48] adb_path: '/home/quintus/Android/Sdk/platform-tools/adb'
I0425 23:41:22.628666 140469032242048 adb_controller.py:62] self._os_env_vars: {'SHELL': '/bin/bash', 'SESSION_MANAGER': 'local/quintus-omen-22:@/tmp/.ICE-unix/2907,unix/quintus-omen-22:/tmp/.ICE-unix/2907', 'QT_ACCESSIBILITY': '1', 'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/etc/xdg', 'SSH_AGENT_LAUNCHER': 'gnome-keyring', 'XDG_MENU_PREFIX': 'gnome-', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'GTK_IM_MODULE': 'fcitx', 'CONDA_EXE': '/home/quintus/anaconda3/bin/conda', '_CE_M': '', 'TERMINAL_EMULATOR': 'JetBrains-JediTerm', 'LANGUAGE': 'en_US:en', 'LC_ADDRESS': 'zh_CN.UTF-8', 'GNOME_SHELL_SESSION_MODE': 'ubuntu', 'LC_NAME': 'zh_CN.UTF-8', 'SSH_AUTH_SOCK': '/run/user/1000/keyring/ssh', 'MESA_LOADER_DRIVER_OVERRIDE': 'i965', 'TERM_SESSION_ID': 'f8a9a0a8-528d-4868-8304-03d666e4b424', 'XMODIFIERS': '@im=fcitx', 'DESKTOP_SESSION': 'ubuntu', 'LC_MONETARY': 'zh_CN.UTF-8', 'GTK_MODULES': 'gail:atk-bridge', 'PWD': '/home/quintus/Aalto/android_env/examples', 'XDG_SESSION_DESKTOP': 'ubuntu', 'LOGNAME': 'quintus', 'XDG_SESSION_TYPE': 'x11', 'CONDA_PREFIX': '/home/quintus/anaconda3/envs/android_py', 'GPG_AGENT_INFO': '/run/user/1000/gnupg/S.gpg-agent:0:1', 'SYSTEMD_EXEC_PID': '2926', 'XAUTHORITY': '/run/user/1000/gdm/Xauthority', 'GJS_DEBUG_TOPICS': 'JS ERROR;JS LOG', 'WINDOWPATH': '2', 'LD_PRELOAD': '/usr/lib/x86_64-linux-gnu/libstdc++.so.6', 'HOME': '/home/quintus', 'USERNAME': 'quintus', 'LANG': 'en_US.UTF-8', 'LC_PAPER': 'zh_CN.UTF-8', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'XDG_CURRENT_DESKTOP': 'ubuntu:GNOME', 'CONDA_PROMPT_MODIFIER': '(android_py) ', 'INVOCATION_ID': '9900c79706ca4023b4eaecb8b7ba5067', 'MANAGERPID': '2452', 'GJS_DEBUG_OUTPUT': 'stderr', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'XDG_SESSION_CLASS': 'user', 'TERM': 'xterm-256color', 'LC_IDENTIFICATION': 'zh_CN.UTF-8', '_CE_CONDA': '', 'LESSOPEN': '| /usr/bin/lesspipe %s', 'LIBVIRT_DEFAULT_URI': 'qemu:///system', 'USER': 'quintus', 'CONDA_SHLVL': '2', 'DISPLAY': ':1', 'SHLVL': '1', 'LC_TELEPHONE': 'zh_CN.UTF-8', 'QT_IM_MODULE': 'fcitx', 'LC_MEASUREMENT': 'zh_CN.UTF-8', 'PAPERSIZE': 'a4', 'CONDA_PYTHON_EXE': '/home/quintus/anaconda3/bin/python', 'LD_LIBRARY_PATH': '/usr/local/cuda/lib', 'XDG_RUNTIME_DIR': '/run/user/1000', 'CONDA_DEFAULT_ENV': 'android_py', 'LC_TIME': 'zh_CN.UTF-8', 'JOURNAL_STREAM': '8:47923', 'XDG_DATA_DIRS': '/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop:/opt/apps/com.qq.weixin.deepin/entries', 'PATH': '/home/quintus/anaconda3/envs/android_py/bin:/home/quintus/anaconda3/condabin:/home/quintus/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/quintus/Android/Sdk/emulator:/home/quintus/Android/Sdk/platform-tools:/usr/local/cuda/bin', 'GDMSESSION': 'ubuntu', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1000/bus', 'CONDA_PREFIX_1': '/home/quintus/anaconda3', 'GIO_LAUNCHED_DESKTOP_FILE_PID': '4748', 'GIO_LAUNCHED_DESKTOP_FILE': '/usr/share/applications/android-studio.desktop', 'LC_NUMERIC': 'zh_CN.UTF-8', 'OLDPWD': '/home/quintus/Aalto/android_env', '_': '/home/quintus/anaconda3/envs/android_py/bin/python3'}
I0425 23:41:22.638464 140469032242048 adb_controller.py:128] Executing ADB command: [adb -P 5037 devices]
I0425 23:41:22.843396 140469032242048 emulator_simulator.py:171] Initialized simulator with ADB server port 5037.
I0425 23:41:22.844423 140469032242048 emulator_simulator.py:188] emulator_launcher_args: {'avd_name': 'my_avd_keyboard_2', 'android_avd_home': '/home/quintus/.android/avd', 'android_sdk_root': '/home/quintus/Android/Sdk', 'emulator_path': '/home/quintus/Android/Sdk/emulator/emulator', 'run_headless': False, 'gpu_mode': 'swiftshader_indirect', 'adb_path': '/home/quintus/Android/Sdk/platform-tools/adb', 'adb_port': 5555, 'adb_server_port': 5037, 'emulator_console_port': 41953, 'grpc_port': 8554, 'tmp_dir': '/tmp/android_env/simulator'}
I0425 23:41:22.845892 140469032242048 emulator_launcher.py:97] Simulator local_tmp_dir: /tmp/android_env/simulator/simulator_instance_a73ox1z0
I0425 23:41:22.850955 140469032242048 task_manager.py:93] Task config: id: "apple_flinger_M_1_1"
name: "Apple Flinger - M_1_1"
description: "Use a slingshot to shoot with apples."
setup_steps {
success_condition {
check_install {
package_name: "com.gitlab.ardash.appleflinger.android"
timeout_sec: 10.0
}
}
adb_request {
install_apk {
filesystem {
path: "2020.08.21-apple-flinger-debug.apk"
}
}
}
}
setup_steps {
adb_request {
settings {
name_space: SYSTEM
put {
key: "user_rotation"
value: "0"
}
}
}
}
reset_steps {
adb_request {
force_stop {
package_name: "com.gitlab.ardash.appleflinger.android"
}
}
}
reset_steps {
adb_request {
package_manager {
clear {
package_name: "com.gitlab.ardash.appleflinger.android"
}
}
}
}
reset_steps {
success_condition {
num_retries: 10
wait_for_app_screen {
app_screen {
activity: "com.gitlab.ardash.appleflinger.android/com.gitlab.ardash.appleflinger.android.AndroidLauncher"
}
timeout_sec: 10.0
}
}
adb_request {
start_activity {
full_activity: "com.gitlab.ardash.appleflinger.android/com.gitlab.ardash.appleflinger.android.AndroidLauncher"
extra_args: "--ez"
extra_args: "\"RL_TASK_ENABLED\""
extra_args: "\"true\""
extra_args: "--es"
extra_args: "\"RL_TASK_GAME_CONFIG\""
extra_args: "\"{\\\"mission\\\":\\\"M_1_1\\\",\\\"simple\\\":true}\""
force_stop: true
}
}
}
reset_steps {
adb_request {
start_screen_pinning {
full_activity: "com.gitlab.ardash.appleflinger.android/com.gitlab.ardash.appleflinger.android.AndroidLauncher"
}
}
}
expected_app_screen {
activity: "com.gitlab.ardash.appleflinger.android/com.gitlab.ardash.appleflinger.android.AndroidLauncher"
}
max_episode_sec: 7200.0
log_parsing_config {
filters: "AndroidRLTask:V"
log_regexps {
score: "^[Ss]core: ([-+]?[0-9]*\\.?[0-9]*)$"
reward: "^[Rr]eward: ([-+]?[0-9]*\\.?[0-9]*)$"
episode_end: "^episode[ _]end$"
extra: "^extra: (?P<name>[^ ]*)[ ]?(?P<extra>.*)$"
json_extra: "^json_extra: (?P<json_extra>.*)$"
}
}
extras_spec {
name: "playing"
shape: 1
dtype: INT8
}
extras_spec {
name: "player"
shape: 1
dtype: INT8
}
extras_spec {
name: "state"
shape: 1
dtype: STRING_U16
}
I0425 23:41:22.851767 140469032242048 coordinator.py:119] Starting the simulator...
I0425 23:41:22.851903 140469032242048 coordinator.py:218] Simulator launch attempt 1 of 3
I0425 23:41:22.852013 140469032242048 emulator_simulator.py:226] Attempt 1 at launching the Android Emulator ('emulator-5554')
I0425 23:41:22.852108 140469032242048 emulator_launcher.py:105] Booting new emulator [/home/quintus/Android/Sdk/emulator/emulator]
I0425 23:41:22.852205 140469032242048 emulator_launcher.py:123] extra_env_vars: ANDROID_HOME= ANDROID_SDK_ROOT=/home/quintus/Android/Sdk ANDROID_AVD_HOME=/home/quintus/.android/avd ANDROID_EMULATOR_KVM_DEVICE=/dev/kvm ANDROID_ADB_SERVER_PORT=5037 LD_LIBRARY_PATH=/home/quintus/Android/Sdk/emulator/lib64/x11/:/home/quintus/Android/Sdk/emulator/lib64/qt/lib/:/home/quintus/Android/Sdk/emulator/lib64/gles_swiftshader/:/home/quintus/Android/Sdk/emulator/lib64/ QT_XKB_CONFIG_ROOT=/home/quintus/Android/Sdk/emulator/qt_config/ ANDROID_EMU_ENABLE_CRASH_REPORTING=1
I0425 23:41:22.852523 140469032242048 emulator_launcher.py:154] Emulator launch command: /home/quintus/Android/Sdk/emulator/emulator -adb-path /home/quintus/Android/Sdk/platform-tools/adb -gpu swiftshader_indirect -no-audio -show-kernel -verbose -avd my_avd_keyboard_2 -grpc 8554 -ports 41953,5555 -no-snapshot
I0425 23:41:22.855114 140469032242048 emulator_simulator.py:342] Creating gRPC channel to the emulator on port 8554
When I press Ctrl + C or wait until timeout, the log is as follows:
^CTraceback (most recent call last):
File "run_random_agent.py", line 83, in <module>
app.run(main)
File "/home/quintus/anaconda3/envs/android_py/lib/python3.8/site-packages/absl_py-1.4.0-py3.8.egg/absl/app.py", line 308, in run
_run_main(main, args)
File "/home/quintus/anaconda3/envs/android_py/lib/python3.8/site-packages/absl_py-1.4.0-py3.8.egg/absl/app.py", line 254, in _run_main
sys.exit(main(argv))
File "run_random_agent.py", line 49, in main
with loader.load(
File "/home/quintus/Aalto/android_env/android_env/loader.py", line 72, in load
coordinator = coordinator_lib.Coordinator(simulator, task_manager)
File "/home/quintus/Aalto/android_env/android_env/components/coordinator.py", line 120, in __init__
self._launch_simulator()
File "/home/quintus/Aalto/android_env/android_env/components/coordinator.py", line 223, in _launch_simulator
self._simulator.launch()
File "/home/quintus/Aalto/android_env/android_env/components/simulators/base_simulator.py", line 33, in wrapper
return func(*args, **kwargs)
File "/home/quintus/Aalto/android_env/android_env/components/simulators/base_simulator.py", line 84, in launch
self._launch_impl()
File "/home/quintus/Aalto/android_env/android_env/components/simulators/emulator/emulator_simulator.py", line 242, in _launch_impl
self._emulator_stub, self._snapshot_stub = self._connect_to_emulator(
File "/home/quintus/Aalto/android_env/android_env/components/simulators/emulator/emulator_simulator.py", line 350, in _connect_to_emulator
grpc.channel_ready_future(self._channel).result(timeout=timeout_sec)
File "/home/quintus/anaconda3/envs/android_py/lib/python3.8/site-packages/grpc/_utilities.py", line 139, in result
self._block(timeout)
File "/home/quintus/anaconda3/envs/android_py/lib/python3.8/site-packages/grpc/_utilities.py", line 87, in _block
self._condition.wait(timeout=remaining)
File "/home/quintus/anaconda3/envs/android_py/lib/python3.8/threading.py", line 306, in wait
gotit = waiter.acquire(True, timeout)
KeyboardInterrupt
I0425 23:42:03.872356 140469032242048 emulator_simulator.py:453] Emulator ('emulator-5554') is not up.
I0425 23:42:03.872436 140469032242048 emulator_simulator.py:465] Closing emulator ('emulator-5554')
I0425 23:42:03.872482 140469032242048 emulator_launcher.py:168] Checking if emulator process has finished...
I0425 23:42:03.872592 140469032242048 emulator_launcher.py:179] The emulator process has finished.
When it starts from the emulator, it works fine. When I launch the emulator with the command used by the Emulator launcher:
/home/quintus/Android/Sdk/emulator/emulator -adb-path /home/quintus/Android/Sdk/platform-tools/adb -gpu swiftshader_indirect -no-audio -show-kernel -verbose -avd my_avd_3 -grpc 8554 -ports 37867,5555 -no-snapshot
it shows:
INFO | Android emulator version 32.1.12.0 (build_id 9751036) (CL:N/A)
INFO | Found systemPath /home/quintus/Android/Sdk/system-images/android-33-ext5/google_apis_playstore/x86_64/
INFO | Storing crashdata in: /tmp/android-quintus/emu-crash.db, detection is enabled
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
unknown option: -adb-path
please use -help for a list of valid options
However, if I remove the adb-path option, I can launch the emulator.
Now I am using the Tiramisu (Extension Level 5)
If you have any ideas, please tell me. Thanks!
Oh, that does indicate that this ersion of the Emulator doesn't have support for -adb-path
. Can you try updating your emulator in Android Studio?
When you remove -adb-path
, does everything work fine?
Hi
@kenjitoyama is correct, Android Emulator 32.1.12 (the current stable track), doesn't have this adb-path
feature.
You can find this feature on the Canary track, like version "33.1.2" (https://developer.android.com/studio/emulator_archive)
Hi After updating the emulator, it finally worked! Thank you so much for solving my problem! I updated my Android Emulator to Canary track (version "33.1.2") and I can run the demo!
Hi @quintus0505!
That's great! I'll close this for now then. Good luck with your experiments!
All the best,
Daniel
Hi,
Recently I tried to set up the android_env on my ubuntu22.04, however, I cannot run the environment. Currently, I am on your latest version (commit 3ebb08d), here is my command:
I get this error:
I also tried your previous version (commit d9e0525 on 4 Apr), I ran the same command, and it was blocked when connecting to the emulator:
It seems that the problem is related to "-adb-path", When I run the emulator launch command without -adb-path or run the
run_random_agent.py
without the adb_path inemulator_launcher.py
(https://github.com/deepmind/android_env/blob/main/android_env/components/simulators/emulator/emulator_launcher.py#L143), it can successfully connect the emulator.Could you please tell me how to solve this problem? Thanks!