mobile-dev-inc / dadb

A Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dadb.AdbStreamClosed: ADB stream is closed for localId: e2527064

nassendelft opened this issue · comments

I'm getting the following error when calling dadb.install.

dadb.AdbStreamClosed: ADB stream is closed for localId: e2527064

It looks like it returns a close command immediately when it receives the abb_execute command.

When the server receives the message it only returns the close command if it can't read the response for some reason.
https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/adb.cpp;drc=867c71e5114e76b4f64e9f38e1be060fd9ba3a26;l=475

Sending shell commands work fine. Calling the install command through adb on my local machine to the same target host also works fine.

Thanks for reporting this. Would you mind providing some more details on your setup? I'm hoping to be able to repro in order to debug this.

Sure, what do you need to know?
I've tested this with 2 remote devices i have on my network and a local running emulator all with the same error.
I'm running this on osx 11.6 with jvm16

What version of Android emulator are you running?

9, same as the actual device i was trying.
Oh another point that might be important... it's an android TV emulator. but having the same issue with an android tablet

I just tested a few emulators and it seems to not work on <= 9 devices.
After going through google's sources my guess would be that streaming install is not supported but pushes the file to android tmp file system and then call the pm install shell command instead:
https://cs.android.com/android/platform/superproject/+/master:packages/modules/adb/client/adb_install.cpp;l=518;drc=867c71e5114e76b4f64e9f38e1be060fd9ba3a26;bpv=0;bpt=1

using push + install works fine

Edit:
This quick workaround works for me until you fix this in the library:

fun Dadb.install2(file: File, vararg options: String) {
  val sdkVersion = shell("getprop ro.build.version.sdk").output.trimEnd().toInt()
  if (sdkVersion <= 28) {
    push(file, "/data/local/tmp/${file.name}")
    val command = listOf("pm", "install") + options
    shell((command + "/data/local/tmp/${file.name}").joinToString(" "))
  } else {
    install(file, *options)
  }
}

@nassendelft I truly appreciate you putting in the time to debug this on your end. I will push up a fix ASAP and deploy. I'll update this thread once the new version is available.