Mono.AndroidTools.AdbException: Attempted to read past the end of the stream (on visual studio)
Asked Answered
I

6

6

I am building an APP using Xamarin / Visual studio for Mac

I have already a project on an Mac mini.

And now I moved that project to an new iMac.

Compile is good. But when trying deploy to a physical device. It got error

"Mono.AndroidTools.AdbException: Attempted to read past the end of the stream"

If I create a new project on the new iMac. It can deploy to the device.

But my old project can't.

Here is some log. I am now stuck at here....Thank you!

80% ... 32128kb of 40140kb copied
90% ... 36160kb of 40140kb copied
100% ... 40140kb of 40140kb copied
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): warning ADB1000:  Failed to delete package file: One or more errors occurred. (One or more errors occurred. (One or more errors occurred. (device '9f5f1695' not found)))
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:  Deployment failed
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: Mono.AndroidTools.AdbException: Attempted to read past the end of the stream. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Mono.AndroidTools.Util.ReadFullAsyncResult.EndRead (System.IAsyncResult ar) [0x00024] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Util/StreamExtensions.cs:95 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Mono.AndroidTools.Adb.AdbSyncClient.FileWrite_OnReadStatus (System.IAsyncResult ar) [0x0000c] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbSyncClient.cs:619 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:    --- End of inner exception stack trace ---
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError (System.Threading.CancellationToken token) [0x0002a] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Util/AggregateAsyncResult.cs:72 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Mono.AndroidTools.Adb.AdbSyncClient.EndPush (System.IAsyncResult result) [0x00006] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbSyncClient.cs:771 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs:534 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: --- End of stack trace from previous location where exception was thrown ---
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000: 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x0008f] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:180 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at AndroidDeviceExtensions.PushAndInstallPackage (Mono.AndroidTools.AndroidDevice device, System.String apkFile, System.String packageName, System.Boolean reinstall, Mono.AndroidTools.Adb.AdbProgressReporter notifyProgress, System.Threading.CancellationToken token) [0x003ce] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:203 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at AndroidDeviceExtensions.InstallSharedRuntimeAsync (Mono.AndroidTools.AndroidDevice device, System.String runtimeFile, Mono.AndroidTools.Adb.AdbProgressReporter progress, System.Threading.CancellationToken token) [0x000ac] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:433 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at AndroidDeviceExtensions.InstallSharedRuntimeAsync (Mono.AndroidTools.AndroidDevice device, System.Boolean provideFullDebugRuntime, System.Threading.CancellationToken cancellationToken, Xamarin.AndroidTools.IProgressNotifier progressReporter) [0x000ac] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:630 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.CheckAndInstallSharedRuntimeAsync () [0x0009c] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:321 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.EnsureCorrectSharedRuntimes () [0x000f2] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:258 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.RunAsync (System.Threading.CancellationToken token) [0x001f9] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:198 
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(579,2): error ADB1000:   at Xamarin.AndroidTools.AndroidDeploySession.RunLoggedAsync (System.Threading.CancellationToken token) [0x0002f] in /Users/builder/azdo/_work/30/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Sessions/AndroidDeploySession.cs:123 
Inclination answered 15/1, 2021 at 16:25 Comment(1)
Now it fixed by rebooting the MacInclination
S
2

To resolve issue on my Mac I had to type

adb uninstall Mono.Android.DebugRuntime 

sometimes when this bug happens adb was disconnecting from device, and had to type also

adb kill-server

UPDATE: Another apps would sometimes gave me similar error and uninstalling Mono.Android.DebugRuntime didn't help.

I ran out of ideas and factory reset of my macbook did the trick. No more problems with installing app on devices. Sometimes fresh start is the best way :)

Segarra answered 26/5, 2021 at 11:46 Comment(0)
L
2

I am using Visual Studio 2022, Windows 10,

Having the same error message, changing USB port or USB cable doesn't work,

Run commands doesn't work:

adb uninstall Mono.Android.DebugRuntime

adb kill-server

But restarting the computer WORKS!

Lytton answered 10/11, 2022 at 15:6 Comment(0)
M
1

In my case it did help to kill -9 all running dotnet processes in the background (there where a bunch).

Soft kill might also work, I did not test it, but be careful if you are currently compiling something or doing other stuff, you don't want to stop.

One tool to achieve that is btop (brew install btop)

  • Start btop
  • Hit f for filter
  • Type dotnet to show all dotnet processes
  • Select them with arrow keys and press k followed by y to kill a process

After killing every process (except one I could not kill), the build worked like expected.

Merrygoround answered 1/4, 2023 at 12:28 Comment(0)
T
0

Upgrading to Visual Studio Community 2022 version 17.8.3 solved it for me.

Rebooting, deleting bin and obj, closing and opening VS, did nothing for me.

Teresetereshkova answered 3/1 at 21:23 Comment(0)
R
0

For my case, it works by restart android device setting using the Developer Options.

Use these steps:

Setting>System>Developer Options> Use developer options>Restart Device>Restart

And then, configure your android in mode developer options. Use these steps:

Setting>About phone>Version> then click Build number 7x

Then run your code using Visual Studio 2022.

Rubberneck answered 16/6 at 14:20 Comment(0)
I
-1

This was fixed by reboot the Mac....

Inclination answered 16/1, 2021 at 3:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.