From b2be6d63daae6d1d24d3c150ef73e0ba2f40a16c Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Fri, 6 Sep 2024 17:00:49 +0200 Subject: [PATCH] fix --- .github/workflows/test.yml | 3 +-- dadb/src/main/kotlin/dadb/AdbStream.kt | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4c0585..18c7dff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,7 @@ jobs: env: ANDROID_HOME: /home/runner/androidsdk ANDROID_SDK_ROOT: /home/runner/androidsdk + ANDROID_USER_HOME: /home/runner/.android ANDROID_OS_IMAGE: system-images;android-29;google_apis;x86_64 steps: @@ -78,8 +79,6 @@ jobs: --package "$ANDROID_OS_IMAGE" \ --name "MyAVD" - - name: Configure AVD - run: | cat << EOF >> ~/.android/avd/MyAVD.avd/config.ini hw.cpu.ncore=2 hw.gpu.enabled=yes diff --git a/dadb/src/main/kotlin/dadb/AdbStream.kt b/dadb/src/main/kotlin/dadb/AdbStream.kt index f9742e3..dfec53c 100644 --- a/dadb/src/main/kotlin/dadb/AdbStream.kt +++ b/dadb/src/main/kotlin/dadb/AdbStream.kt @@ -94,7 +94,7 @@ internal class AdbStreamImpl internal constructor( val bytesWritten = source.read(buffer.array(), buffer.position(), bytesToWrite) // Cast to prevent NoSuchMethodError when mixing Java versions - // Learn more: https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror/ + // Learn more: https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror (buffer as java.nio.Buffer).position(buffer.position() + bytesWritten) if (buffer.remaining() == 0) flush() @@ -103,6 +103,9 @@ internal class AdbStreamImpl internal constructor( override fun flush() { adbWriter.writeWrite(localId, remoteId, buffer.array(), 0, buffer.position()) + + // Cast to prevent NoSuchMethodError when mixing Java versions + // Learn more: https://www.morling.dev/blog/bytebuffer-and-the-dreaded-nosuchmethoderror (buffer as java.nio.Buffer).clear() }