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

Viewed 1387

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 
2 Answers

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 :)

This was fixed by reboot the Mac....

Related