aerokube / selenoid

Selenium Hub successor running browsers within containers. Scalable, immutable, self hosted Selenium-Grid on any platform with single binary.
https://aerokube.com/selenoid/latest/
Apache License 2.0
2.57k stars 322 forks source link

Android 9.0 won't run app without google play services #1022

Closed abayibrayev1 closed 3 years ago

abayibrayev1 commented 3 years ago

using selenoid + docker image (selenoid/android:9.0) https://registry.hub.docker.com/r/selenoid/android

Facing problem with google play services image

Tried to use other docker images, but can't configure them with selenoid.

Can u please tell me: 1) how can I configure google play services before starting emulator in selenoid? 2) does selenoid able to work with other docker android images (with google APIs) ?

Thanks in advance!

vania-pooh commented 3 years ago

@abayibrayev1 Selenoid should work with any Android image with Selenium \ Appium inside. Our images by default have no Google APIs but you can build your own using this script: https://github.com/aerokube/images/blob/master/selenium/automate_android.sh

abayibrayev1 commented 3 years ago

Thanks for the fast reply, I solved my problem successfully with automate_android.sh script. Thanks a lot!

jaysonabilar commented 3 years ago

@abayibrayev1 . Hi, may I know what values did you select when you run the automate_android.sh script? like what android version,appium version, android image you select?, because I am also encountering the same issue but when I tried to build an image using the automate_android.sh script, the image is created but I can't create a session or can't run the image emulator .

These are the dd values I selectected: appium version: 1.18.1 android version : 9.0 android image type : google_apis_playstore device: Nexus 5/ Nexus 5X image tag : selenoid/android:9.0

abayibrayev1 commented 3 years ago

@abayibrayev1 . Hi, may I know what values did you select when you run the automate_android.sh script? like what android version,appium version, android image you select?, because I am also encountering the same issue but when I tried to build an image using the automate_android.sh script, the image is created but I can't create a session or can't run the image emulator .

These are the dd values I selectected: appium version: 1.18.1 android version : 9.0 android image type : google_apis_playstore device: Nexus 5/ Nexus 5X image tag : selenoid/android:9.0

Hello, sure, but i remember only this values: Android version 8.1 Android image type google_apis Device default Appium version default No quick boot

It worked for me, so I hope it will help u to solve u problem

jaysonabilar commented 3 years ago

Hi @abayibrayev1 , thanks so much for your response, I tried the same details that you have mentioned, unfortunately I still can't create session, these are errors that I encountered in the container logs when I tried to create session. Not sure if the selenoid docker version can also be the reason, but still, thanks for your help :)

Waiting X server... Waiting X server... Logging to: /tmp/fluxbox.log Waiting X server... Waiting X server... Waiting X server... Waiting X server... Waiting X server... Waiting X server...

--- x11vnc loop: 1 ---

PORT=5900 adb: no devices/emulators found adb: no devices/emulators found adb: no devices/emulators found adb: no devices/emulators found adb: no devices/emulators found adb: no devices/emulators found adb: no devices/emulators found handleCpuAcceleration: feature check for hvf cannot add library /opt/android-sdk-linux/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so: failed added library /opt/android-sdk-linux/emulator/lib64/vulkan/libvulkan.so cannot add library /opt/android-sdk-linux/emulator/lib64/vulkan/libvulkan.so.1: full adb: no devices/emulators found WARNING. Using fallback path for the emulator registration directory. emulator: WARNING: System image is writable emulator: WARNING: userdata partition is resized from 500 M to 800 M

emulator: INFO: GrpcServices.cpp:288: Started GRPC server at 127.0.0.1:8554, security: Local Your emulator is out of date, please update by launching Android Studio:

adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline adb: device offline

jaysonabilar commented 3 years ago

Hi @abayibrayev1, May I know how did you setup the selenoid hub? . Did you use the cm by selenoid or you manually setup a hub using docker and add the generated emulator image there? Because when I am trying to run the emulator manually using docker I was able to connect to it using this :

docker run -d --name android-test -e ENABLE_VNC=true --privileged -p 4444:4444 -p 5900:5900 selenoid/android:8.1.

But the problem is that I want to connect this to the grid/selenoid hub for me to execute my test using RemoteURL. May I know the steps or documentation that you followed to setup the selenoid hub and generated emulator image?

abayibrayev1 commented 3 years ago

Hi @abayibrayev1, May I know how did you setup the selenoid hub? . Did you use the cm by selenoid or you manually setup a hub using docker and add the generated emulator image there? Because when I am trying to run the emulator manually using docker I was able to connect to it using this :

docker run -d --name android-test -e ENABLE_VNC=true --privileged -p 4444:4444 -p 5900:5900 selenoid/android:8.1.

But the problem is that I want to connect this to the grid/selenoid hub for me to execute my test using RemoteURL. May I know the steps or documentation that you followed to setup the selenoid hub and generated emulator image?

Hi. sure. I configured selenoid + android images (without any appium configuration) on my local PC Ubuntu 20.04 (not remote). Here the steps, that i did:

  1. downloaded cm package (official, latest)
  2. installed selenoid and selenoid-ui through cm (selenoid 1.10.0, selenoid-ui 1.10.2)
  3. tried firstly to run autotests on default selenoid android images https://hub.docker.com/r/selenoid/android (without google_apis configuration 8.1) - here u need to verify that after running autotest, selenoid can start android emulator succesfully and launch apk
  4. then I just deleted default and recreated it using automate_android.sh script

I can't remember if I had any major issues, so I hope it will help u.

And my small advice, try firstly simply connect selenoid with default android emulators from docker hub, and after u will have completed flow (autotest -> selenoid hub -> emulator launch) then specify ur own images

jaysonabilar commented 3 years ago

Hi @abayibrayev1 , Thanks so much for the detailed instructions. This is really a great help for us. Thanks a lot :)

AlexeyAltunin commented 2 years ago

Hi @JaysonAbilar . Is your problem solved? as we still facing the same issue looking on docker logs:

Waiting X server... Waiting X server... Waiting X server... Waiting X server... Waiting X server... Waiting X server...

We used this instruction https://github.com/TimurNurlygayanov/test-tasks-example/blob/master/selenoid-android/README.md as we need playstore support

Appium version: 1.18.1 Android image type: google_apis_playstore Application Binary Interface: x86 Android Version: 9.0 image tag: android9_google_play

Can be any compatibility issues between custom Android image that we create and Selenoid Server? Container is run and in queue but emulator still not running

@vania-pooh Ivan, hi. It would be great if you can recommend smth there

vania-pooh commented 2 years ago

@AlexeyAltunin the problem is that when you enable play store, then during the boot of emulator you have to manually close a dialog related to USB debugging if I remember correctly. And because of that nothing works. Did not do more research, probably there is a property allowing to suppress this dialog.

AlexeyAltunin commented 2 years ago

@AlexeyAltunin the problem is that when you enable play store, then during the boot of emulator you have to manually close a dialog related to USB debugging if I remember correctly. And because of that nothing works. Did not do more research, probably there is a property allowing to suppress this dialog.

Ivan, thanks. We will try to research in this direction as well . But when we run container separately without Selenoid to do google auth:

docker run -d --name android-test -e ENABLE_VNC=true --privileged -p 4444:4444 -p 5900:5900

It worked fine

AlexeyAltunin commented 2 years ago

I finally found and fixed the issue. It was our mistake.

When we created a custom image with google play we used this instruction: https://github.com/TimurNurlygayanov/test-tasks-example/blob/master/selenoid-android/README.md

There was a step

  1. Connect to VNC on localhost:5900, run Google Play service, authorize with your google account. When we launched simulator , it created a file /tmp/.X99-lock . After that we saved our custom image, including the file.

After launching a container via Selenoid there was a message:

Fatal server error: (EE) Server is already active for display 99 If this server is no longer running, remove /tmp/.X99-lock and start again. Waiting X server... Waiting X server... Waiting X server...

So, the first step was removing the file /tmp/.X99-lock , otherwise it will say that 99 is already active The second that you need to do is killing the emulator adb -s emulator-5554 emu kill , otherwise when you run via Selenoid you will get a message

Running multiple emulators with the same AVD is an experimental feature. Please use -read-only flag to enable this feature.

And only after that you can save a custom image!