android: VS doesn't show physical device - getting AdbException on "getprop" step
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 - 17.7.3; Xamarin.Android SDK 13.2.1.2 (d17-5/a8a26c7)
Description
Not sure it’s the right place to open issue but can’t think of anything better.
adb correctly detects physical device while VS doesn’t add it to the list. There’re plenty of similar Qs on SO:
https://stackoverflow.com/questions/70224238/visual-studio-2022-android-device-not-found https://stackoverflow.com/questions/25888188/visual-studio-doesnt-let-me-debug-on-android-physical-device
Tried to install different drivers, turn on/off debug allowance, change connection options,… And nothing.
Logs from Xamarin.Diagnostics:
[I:]: Got new device list from adb with 1 devices
[D:RunShellCommand]: IREQJ7DU85YPAQEI getprop
-- Start GetProperties - 09/12/2023 17:00:39 (43.4969ms) --
[INPUT] getprop
[OUTPUT]
[Build.BRAND]: [MTK]
// ... other properties are omitted
[vold.storage.prepared]: [1]
-- End GetProperties --
[E:]: Error getting properties from device 'IREQJ7DU85YPAQEI'
Mono.AndroidTools.AdbException: Unknown property format: ']'
at Mono.AndroidTools.Internal.AdbOutputParsing.ParseGetprop(String properties) in D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 104
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Mono.AndroidTools.AndroidDevice.<RefreshProperties>d__52.MoveNext() in D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 288
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Mono.AndroidTools.DevicePropertiesTracker.<GetAndAnnotatePropertiesAsync>d__9.MoveNext() in D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\AndroidDeviceManager.cs:line 532
Steps to Reproduce
no repro, didn’t see this issue on other systems
Did you find any workaround?
nope
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (6 by maintainers)
This is a duplicate of: https://developercommunity.visualstudio.com/t/Connecting-to-Android-device-Newland-f/10424915
This was fixed on 2023-Aug-12 in: https://github.com/xamarin/androidtools/commit/09dce7939bc4fcba2c970103c3ff4eb3c065804b
Unfortunately, the fix has not yet been released. Commit 29c7de2a85e6b12b5233ed79067e23b8667a0c63 contains the fix, which in turn is included in our (forthcoming) .NET 8 RC1 release, and we’ll also need the IDEs to pick up this fix as well. (Hopefully Visual Studio (Windows) 17.8 Preview 3 will contain this fix.)
In the meantime/as a workaround, find the “offending” system property and remove it, if possible.
Which property is the “offending” system property? The one that has
]without a preceding[on the same line when readingadb shell getprop.For example, the following
adb shell setpropcommand creates adebug.multiline.examplesystem property which will cause theUnknown property formaterror:When reading
adb shell getprop, you’ll see:To “fix” the error, remove the offending system property:
Note: this only works if you can modify the offending system property…