google / android-emulator-container-scripts

Apache License 2.0
1.89k stars 267 forks source link

Failure to launch #328

Closed jpayne-procella closed 1 year ago

jpayne-procella commented 1 year ago

This PR fixes 2 problems I ran into when trying to run this project.

The first one is a simple order of operations. /root/.android doesn't exist in the container until clean_up is called. However, initialize_data_part tries place a softlink in that directory, resulting in this error:

emulator_1     | ERROR   | Unknown AVD name [Pixel2], use -list-avds to see valid list.
emulator_1     | ERROR   | HOME is defined but there is no file Pixel2.ini in $HOME/.android/avd
emulator_1     | ERROR   | (Note: Directories are searched in the order $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/avd and $HOME/.android/avd)

Switching the order of clean_up then initialize_data_part solves this.

The second one was more frustrating. Using the examples to utilize TURN was failing because var_append wasn't handling 'printf JSON_BLOB' and instead exec was just receiving 'printf':

echo $TURN
printf {"iceServers":[{"urls":"turn:","username":"webrtc","credential":"turnpassword"}]}
emulator/emulator -avd Pixel2 -ports 5556,5557 -grpc 8554 -no-window -skip-adb-auth -no-snapshot-save -wipe-data -no-boot-anim -shell-serial file:/tmp/android-unknown/kernel.log -logcat *:V -logcat-output /tmp/android-unknown/logcat.log -logcat *:V -feature AllowSnapshotMigration -gpu swiftshader_indirect -shell-serial file:/tmp/android-unknown/kernel.log -logcat-output /tmp/android-unknown/logcat.log -turncfg 'printf {"iceServers":[{"urls":"turn:","username":"webrtc","credential":"turnpassword"}]}' -qemu -append panic=1
INFO    | Android emulator version 32.1.11.0 (build_id 9536276) (CL:N/A)
INFO    | Found systemPath /android/sdk/system-images/android/x86_64/
INFO    | Crashreporting disabled, not reporting crashes.
INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
invalid command-line parameter: {"iceServers":[{"urls":"turn:","username":"webrtc","credential":"turnpassword"}]}'.

Fixed this by switching to bash to allow bash arrays, changing var_append to construct an array, and switching the call to exec to use the array.

I just submitted a CLA - hopefully that gets processed in time to accept this PR.

Thanks! John Payne Procella Technologies

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

pokowaka commented 1 year ago

We took your fix in a slightly different way! Thank you for your help!