Android: Cannot deploy & debug on physical device (Android 12) with VS4Mac
See original GitHub issueDescription
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:
- Created 2 months ago
- Reactions:1
- Comments:10 (5 by maintainers)
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.
@dellis1972 I will try when I get the chance.