Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to run on AWS Device Farm for Android >= 10 #425

Closed
Almouro opened this issue Nov 18, 2022 · 13 comments
Closed

Fail to run on AWS Device Farm for Android >= 10 #425

Almouro opened this issue Nov 18, 2022 · 13 comments
Labels
bug Something isn't working platform: android Testing Android apps is affected

Comments

@Almouro
Copy link

Almouro commented Nov 18, 2022

Hi! Thanks for providing Maestro to the community! ❤️

Trying to run Maestro in AWS Device Farm, I've noticed Android devices with version 10 and above will fail to run Maestro (basically devices supporting abb_exe)

It fails here: https://github.com/mobile-dev-inc/dadb/blob/master/dadb/src/main/kotlin/dadb/Dadb.kt#L85 seemingly printing out the output of running adb shell cmd package as if everything after package was ignored:

java.io.IOException: Failed to install apk /tmp/maestro-app8381517088354451654.apk: Install failed: Package manager (package) commands:
  help
    Print this help text.

  path [--user USER_ID] PACKAGE

...

	at dadb.Dadb$DefaultImpls.install(Dadb.kt:85)
	at dadb.adbserver.AdbServerDadb.install(AdbServer.kt:118)
	at maestro.drivers.AndroidDriver.install(AndroidDriver.kt:424)
	... 15 more

If I run Dadb from source on AWS, I'm running into the same issue.
I can log the commands sent via abb:

For instance, with:

val dadb = Dadb.discover()
val workingDir = System.getProperty("user.dir")
dadb?.install(File(workingDir + File.separator + "blank.apk"))

I see:

host:devices
host:transport:R9AR207LM2J
host:features
host:transport:R9AR207LM2J
abb_exec:package�install�-S�1656660

If I force dadb to use the second version to install an APK (without abb), it works succesfully.

Kinda wondering if there is an issue with the null symbol \u0000 not being recognized somehow on AWS machines.
AWS Device Farm runs with Ubuntu 14 LTS / Java 8 / adb 1.0.39.
I've upgraded both java and adb and I'm still running in the same issue though

Any ideas what could be going on, what to try out next?

@vibin
Copy link

vibin commented Apr 5, 2023

Hi @Almouro - are you using Custom test environments in AWS device farm?
If yes, can you share the install and pre_test phases of your AWS device farm script?

@Almouro
Copy link
Author

Almouro commented Apr 20, 2023

Hi @vibin, sure here's a simple example to reproduce:

version: 0.1

phases:
  install:
    commands:
      - curl -Ls "https://get.maestro.mobile.dev" | bash
      - export PATH="$PATH":"$HOME/.maestro/bin"
      - echo YXBwSWQ6IGNvbS5leGFtcGxlCi0tLQotIGxhdW5jaEFwcAotIGFzc2VydFZpc2libGU6IC4qLioK | base64 -d > test.yaml
  test:
    commands:
      - maestro test test.yaml

@vibin
Copy link

vibin commented Apr 20, 2023

Hi @vibin, sure here's a simple example to reproduce:

version: 0.1

phases:
  install:
    commands:
      - curl -Ls "https://get.maestro.mobile.dev" | bash
      - export PATH="$PATH":"$HOME/.maestro/bin"
      - echo YXBwSWQ6IGNvbS5leGFtcGxlCi0tLQotIGxhdW5jaEFwcAotIGFzc2VydFZpc2libGU6IC4qLioK | base64 -d > test.yaml
  test:
    commands:
      - maestro test test.yaml

Hi @Almouro, you mentioned you tried upgrading ADB. Is that done as part of the install phase? Can you share the snippet for that?

@Almouro
Copy link
Author

Almouro commented Apr 20, 2023

Indeed, here goes:

version: 0.1

phases:
  install:
    commands:
      # Upgrade java
      - java -version
      - curl -s "https://get.sdkman.io" | bash
      - source "$HOME/.sdkman/bin/sdkman-init.sh"
      - sdk install java
      - echo "Java upgraded"
      - java -version
      # Upgrade adb
      - adb version
      - wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
      - unzip platform-tools-latest-linux.zip
      - export PATH=$(pwd)/platform-tools:$PATH
      - echo "ADB upgraded"
      - adb version
      # Install Maestro
      - curl -Ls "https://get.maestro.mobile.dev" | bash
      - export PATH="$PATH":"$HOME/.maestro/bin"
      - echo YXBwSWQ6IGNvbS5leGFtcGxlCi0tLQotIGxhdW5jaEFwcAotIGFzc2VydFZpc2libGU6IC4qLioK | base64 -d > test.yaml
  test:
    commands:
      - maestro test test.yaml

@tomoakley
Copy link

tomoakley commented Jun 16, 2023

I'm also experiencing the same issue.

If I force dadb to use the second version to install an APK (without abb), it works succesfully.

@Almouro can you share some more details on what this means? How is that achieved?

Were you able to find a workaround to get Maestro + AWS DF to work together?

@vibin
Copy link

vibin commented Jun 17, 2023

Hi @tomoakley, I think @Almouro is referring to the if-else conditional in the Dadb.install function.

    fun install(file: File, vararg options: String) {
        if (supportsFeature("abb_exec")) {
            abbExec("package", "install", "-S", file.length().toString(), *options).use { stream ->
                stream.sink.writeAll(file.source())
                stream.sink.flush()
                val response = stream.source.readString(Charsets.UTF_8)
                if (!response.startsWith("Success")) {
                    throw IOException("Install failed: $response")
                }
            }
        } else {
            val fileName = file.name
            val remotePath = "/data/local/tmp/$fileName"
            push(file, remotePath)
            shell("pm install ${options.joinToString(" ")} \"$remotePath\"")
        }
    }

More on abb_exec here: https://malinskiy.github.io/adam/docs/abb

Though, how to execute the else branch on Android 10+ remains unknown...

@Almouro
Copy link
Author

Almouro commented Jun 19, 2023

Indeed, we just forked it replacing the condition with if (false) 🙈

Since we have node installed on the aws machine, we run it with npx @perf-profiler/maestro@rc test instead of just maestro test

@tomoakley
Copy link

tomoakley commented Jun 19, 2023

thanks @vibin @Almouro, very helpful. Will try using that package and see if it works for me!

edit: it works! thanks so much @Almouro 🎉

@khoafonos
Copy link

@Almouro : can you update @perf-profiler/maestro since its missing --debug-output command

@vibin
Copy link

vibin commented Sep 5, 2023

Dadb v1.2.7 replaces abb_exec with exec:cmd: mobile-dev-inc/dadb#63

Waiting for Maestro to upgrade Dadb to new version...

commons-codec = "1.15"
dadb = "1.2.6"
detekt = "1.19.0"

@vibin
Copy link

vibin commented Sep 23, 2023

@axelniklasson @Leland-Takamine Could you please take up the Dadb upgrade in the next Maestro release?

@Almouro
Copy link
Author

Almouro commented Aug 9, 2024

Retested with latest Maestro version and it works for me now 👌🥳

@Almouro Almouro closed this as completed Aug 9, 2024
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.
Thank you for helping keep us our issue tracker clean!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working platform: android Testing Android apps is affected
Projects
None yet
Development

No branches or pull requests

6 participants