maestro icon indicating copy to clipboard operation
maestro copied to clipboard

[Android] Failed to install maestro-app.apk; IOException: Install failed

Open YkSix opened this issue 2 years ago • 18 comments

💡 Workaround

One possible workaround for this issue is to connect the device over Wi-Fi, which can help to mitigate the problem.

Document for connecting to a device over Wi-Fi

  • https://developer.android.com/tools/adb#connect-to-a-device-over-wi-fi
  • https://developer.android.com/studio/run/device#wireless

When I run maestro studio or maestro test, I encountered error: IOException: Install failed It works well in an emulator and another new real device.

What I have tried:

  1. Reboot Android device
  2. Reboot Macbook
  3. Uninstall dev.mobile.maestro by command: adb uninstall dev.mobile.maestro

Failure [DELETE_FAILED_INTERNAL_ERROR]

  1. Uninstall dev.mobile.maestro.test
  2. Install maestro-app.apk by adb install -r -d maestro-app.apk
  3. When I listed all packages in device, no maestro-related app were found.

adb shell pm list packages -f | grep maestro

kill -9 $(lsof -t -i tcp:7001)
kill -9 $(lsof -t -i tcp:9999)
  1. Deselect options in "Play Protect settings"

Environment

Android device:

Google Pixel 4 (Android 13)

macOS

Ventura 13.2 (Apple M1 Max)

maestro

  • 1.23.0
  • 1.26.1

Error logs

java.io.IOException: Failed to install apk /var/folders/87/xrrt4s0n3f585qj0n0twqk500000gp/T/maestro-app7643778700515813176.apk: Install failed: 
	at maestro.drivers.AndroidDriver.install(AndroidDriver.kt:552)
	at maestro.drivers.AndroidDriver.installMaestroApks(AndroidDriver.kt:532)
	at maestro.drivers.AndroidDriver.open(AndroidDriver.kt:85)
	at maestro.Maestro$Companion.android(Maestro.kt:538)
	at maestro.Maestro$Companion.android$default(Maestro.kt:531)
	at maestro.cli.session.MaestroSessionManager.createMaestro(MaestroSessionManager.kt:151)
	at maestro.cli.session.MaestroSessionManager.access$createMaestro(MaestroSessionManager.kt:45)
	at maestro.cli.session.MaestroSessionManager$newSession$session$1.invoke(MaestroSessionManager.kt:80)
	at maestro.cli.session.MaestroSessionManager$newSession$session$1.invoke(MaestroSessionManager.kt:79)
	at maestro.cli.db.KeyValueStore.withExclusiveLock(KeyValueStore.kt:37)
	at maestro.cli.session.SessionStore.withExclusiveLock(SessionStore.kt:74)
	at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:79)
	at maestro.cli.command.StudioCommand.call(StudioCommand.kt:36)
	at maestro.cli.command.StudioCommand.call(StudioCommand.kt:18)
	at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
	at picocli.CommandLine.access$1200(CommandLine.java:145)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
	at maestro.cli.DisableAnsiMixin$Companion.executionStrategy(DisableAnsiMixin.kt:22)
	at picocli.CommandLine.execute(CommandLine.java:2058)
	at maestro.cli.AppKt.main(App.kt:124)
Caused by: java.io.IOException: Install failed: 
	at dadb.Dadb$DefaultImpls.install(Dadb.kt:85)
	at dadb.adbserver.AdbServerDadb.install(AdbServer.kt:118)
	at maestro.drivers.AndroidDriver.install(AndroidDriver.kt:550)
	... 22 more

YkSix avatar Feb 22 '23 16:02 YkSix

I am seeing exactly this after upgrading to Mac OS Ventura 13.2.1

kurtisnelson avatar Feb 22 '23 21:02 kurtisnelson

Workaround: Run against an emulator, this appears to be an issue only with physical devices.

Other trace you might see if the APK is already installed:

Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/0:0:0:0:0:0:0:1:7001
Caused by: java.net.ConnectException: Connection refused
	at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
	at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)

kurtisnelson avatar Feb 22 '23 21:02 kurtisnelson

I cannot use an emulator due to project constraints. Is there a workaround when using a physical device as well?

mressel-bitmarck avatar Feb 23 '23 09:02 mressel-bitmarck

Same error but I'm still using Mac OS Ventura 13.1.

RobinCaroff avatar Feb 28 '23 10:02 RobinCaroff

I am having the same issue on macOS 13.2 on a M1 Pro chip.

ln-12 avatar Mar 10 '23 15:03 ln-12

Anyone know of a workaround? m1 max, macOS 13.2.1

ColtonIdle avatar Mar 19 '23 06:03 ColtonIdle

Note: I have the same error using a Pixel3a it runs fine with a Samsung Galaxy S8.

RobinCaroff avatar Apr 24 '23 14:04 RobinCaroff

Seems to be a USB issue, works if I connect the device via wireless debugging.

ghost avatar Apr 25 '23 20:04 ghost

Seems to be a USB issue, works if I connect the device via wireless debugging.

Thanks! Using wireless debugging does work for me as well. I still wonder if it is related to Maestro as I never encountered debugging issues while using USB with this device appart from the Maestro tests.

RobinCaroff avatar Apr 26 '23 08:04 RobinCaroff

This is a strange issue where I was unable to make any progress with the test script when connected via USB Cable. The moment I connected the mobile device with Wireless Debugging, the Test Script got executed successfully.

bipin-k avatar May 16 '23 09:05 bipin-k

stuck at this! (macOS 12.5.1 )

theapache64 avatar May 25 '23 03:05 theapache64

Same here i just used adb connect and it's worked ;)

himanshumistri avatar Jun 14 '23 11:06 himanshumistri

Strange issue this one. On a Pixel 6A, It would work if connecting to wifi - so when maestro studio is run, you either disconnect the usb cable (so it auto connects to wifi), or choose wifi in the choices it gives you.

Interestingly, on a Samsung phone (S21 ultra), I've had none of these difficulties, and it was working fine - even over USB. I'm not sure what the culprit is.

brett-james-rocketlab avatar Aug 01 '23 04:08 brett-james-rocketlab

Below steps work for Pixel 4a. On your phone swipe down notification drawer > choose Use USB for option> Change this to File Transfer

RahulJanagouda avatar Dec 28 '23 02:12 RahulJanagouda

@RahulJanagouda This is working for me

saleehk avatar Jan 11 '24 01:01 saleehk

wireless debugging works well and if we are debugging through wired connect physical device it throws error

laxkarparas1 avatar Jan 12 '24 08:01 laxkarparas1

I was seeing these errors logged and was unable to run maestro studio on Ubuntu 20.04. But I noticed maestro studio was working well on Ubuntu 22.0.4.

I'm running android x86 in a vm and use adb connect x.x.x.x:5555. This has worked fine across the lan with adb and scrcpy.

On Ubuntu 20.04, maestro would exit with lots of errors, but if I ran it a few times it would start with errors and launch a browser window with spinning, no display and still unusable.

Ubuntu 22.04 on the other hand, starts cleanly. Currently 1.34.1

I managed to get studio working on Ubuntu 20.04 after copying adb and glibc from Ubuntu 22.04.

Ubuntu 20.04.6 LTS:

Android Debug Bridge version 1.0.39
Version 1:8.1.0+r23-5ubuntu2
Installed as /usr/lib/android-sdk/platform-tools/adb.1.0.39

GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.14) stable release version 2.31.

openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-120.04, mixed mode, sharing)

Ubuntu 22.04.3 LTS

Android Debug Bridge version 1.0.41
Version 28.0.2-debian
Installed as /usr/lib/android-sdk/platform-tools/adb

GNU C Library (Ubuntu GLIBC 2.35-0ubuntu3.6) stable release version 2.35.

openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-122.04, mixed mode, sharing)

I don't know if it's adb, GLIBC or both but it seems to work now.

jpmorrison avatar Jan 16 '24 23:01 jpmorrison

You can make maestro work on a USB by enabling for : "File Transfer..."

Xnapper-2024-06-03-17 40 57

joshuadeguzman avatar Jun 03 '24 09:06 joshuadeguzman

Thank you all for sharing your solutions to this problem. Based on these answers (first, second), and the high number of "👍" reactions on them, I assume that mostly fixes this problem.

I think Maestro CLI could try enabling the "File transfer" option itself. I found this on StackOverflow:

adb shell svc usb setFunctions mtp

Maybe support for this could be added to dadb.

bartekpacia avatar Jul 11 '24 12:07 bartekpacia