question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: Cannot deploy & debug on physical device (Android 12) with VS4Mac

See original GitHub issue

Description

I am not able to debug any Android App on device with .NET MAUI (latest workload 7.0.92);

Something is getting deployed to the device, but never starts. Starting manually results in an immediate crash. The deployment task hangs like forever at:

Target _Upload:
    Using cached value from RegisterTaskObject
    Found device: N0AA003638K50600016

Every now and then it gets past that point, then I see a bunch of these errors:

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000: Mono.AndroidTools.AdbException: Attempted to read past the end of the stream.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:  ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Mono.AndroidTools.Util.ReadFullAsyncResult.EndRead(IAsyncResult ar) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Util/StreamExtensions.cs:line 93
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Mono.AndroidTools.Adb.AdbSyncClient.FileWrite_OnReadStatus(IAsyncResult ar) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbSyncClient.cs:line 619
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    --- End of inner exception stack trace ---
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Mono.AndroidTools.Util.AggregateAsyncResult.CheckError(CancellationToken token) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Util/AggregateAsyncResult.cs:line 70
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Mono.AndroidTools.Adb.AdbSyncClient.EndPush(IAsyncResult result) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbSyncClient.cs:line 770
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000: --- End of stack trace from previous location ---
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at AndroidDeviceExtensions.PushAndInstallPackageAsync(AndroidDevice device, PushAndInstallCommand command, CancellationToken token) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:line 198
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at AndroidDeviceExtensions.PushAndInstallPackageAsync(AndroidDevice device, PushAndInstallCommand command, CancellationToken token) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:line 223
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Xamarin.Android.Tasks.FastDeploy.InstallPackage(Boolean installed) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 353
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Xamarin.Android.Tasks.FastDeploy.InstallPackage(Boolean installed) in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 370
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.Debugging.targets(676,5): error ADB1000:    at Xamarin.Android.Tasks.FastDeploy.RunTaskAsync() in /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 216

Deploying a Xamarin.Forms app works without any problems! Deploying to the default Pixel 5 Android API 33 emulator works as well.

Steps to Reproduce

Create a new .NET MAUI App Hit the Debug button

Expected outcome: App gets deployed and debugging starts Actual outcome: Something gets deployed, but most of the time the process gets stuck. If it gets past that step, the above mentioned error is written multiple times in the output window.

Link to public reproduction project repository

Version with bug

Unknown/Other

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12 (unsure about others).

Did you find any workaround?

No

Relevant log output

No response

Issue Analytics

  • State:open
  • Created 2 months ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dellis1972commented, Aug 21, 2023

We are seeing a few issues with hanging deployments on certain android devices. We are currently not sure what causes this problem. It seems to be related to the OS that is installed on the device. Switching to Wireless Debugging or enabling EmbedAssembliesIntoApk are the only work around at this time. Wireless Debugging would probably provide a better experience.

I am working on some better error handling. The idea is to detect when this occurs and use a fallback (but slower method) of fast deployment. But issue a warning that Wireless Debugging might be better for this device.

1reaction
MSicccommented, Jul 25, 2023

@dellis1972 I will try when I get the chance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't select physical Android device for debugging in VS Mac
I CAN deploy to the device by using "Upload to Device" menu option. This makes debugging really painful. I have an old Android...
Read more >
Visual Studio doesn't let me debug on android physical ...
I just ran adb command prompt and hit 'adb devices' and it showed daemon was not running. It installed itself and now i...
Read more >
Visual studio 2022 and Androdi V12 specific: Cannot ...
I have VS 2022 on a Windows machine. V17.1.3 I have updated Android, IOS and XF etc to the latest available as of...
Read more >
Run apps on a hardware device | Android Studio
Learn how to set up your development environment and Android device for testing and debugging over an Android Debug Bridge (ADB) connection.
Read more >
Android device not showing up when debugging : RIDER-19266
Frequently, when debugging, my Android device doesn't show up. When I start VS mac or Android Studio, it is there, so my phone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found