VS 2022 Community x64 17.4.2 still can't debug on Android Galaxy Samsung J5 2016 with Android 7.1.1 using Xamarin with NetStandard2.0 on Windows 10

Foteini Verdou 1 Reputation point
2022-08-31T09:09:31.12+00:00

I have updated my Visual Studio and it stopped deploying to my Android Samsung J5 device. The error I get in Xamarin Diagnostics is

[I:]: Tracking android devices started
[I:]: Got new device list from adb with 1 devices
[E:]: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object[] args)
at Mono.AndroidTools.AndroidLogger.LogError(String task, String format, Object[] args) in D:\a_work\1\s\External\androidtools\Mono.AndroidTools\AndroidLogger.cs:line 63
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass118_0.<RunShellCommandAsync>b__0() in D:\a_work\1\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 1012

The confusing part is that I get

Build succeeded.
1>Deployment was successful to Samsung SM-J510FN.
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

in the Build output. But the app actually seems to start on the phone, I get a white screen but then it closes and VS terminates debugging.

The debug output is this:

This debug engine does not support exception conditions. The condition(s) will be ignored.
Forwarding debugger port 8824
Detecting existing process
Terminated existing process
> am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "com.bshg.iservice5.droid/crc649586142a72936f38.MainActivity"
> Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.bshg.iservice5.droid/crc649586142a72936f38.MainActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }

The Xamarin output is

Successfully connected to Local Broker
Starting IDB Local Agent...
Checking IDB.Local 17.3.0.296 installation...
Starting IDB.Local 17.3.0.296 in port 53826...
IDB.Local 17.3.0.296 started successfully
Successfully started IDB Local Agent
Checking xma 17.3.0.296 installation...
SetSelectedDeviceAsync BEST Local Device

What other information could I share to help resolve this?

Thank you!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,600 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
938 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Foteini Verdou 1 Reputation point
    2022-09-01T09:09:50.517+00:00

    UPDATE

    I had to uninstall visual studio and reinstall the last version that worked, 17.2.6, and that works. But I'd like to have the latest version without any problems.

    0 comments No comments

  2. Foteini Verdou 1 Reputation point
    2022-12-02T11:42:21.313+00:00

    I still have the same issue on Microsoft Visual Studio Community 2022 (64-bit) Version 17.4.2

    I updated after getting a new phone, a Huawei Mate 9 with Android 9, and I could debug on that without problems on the latest updates. But to complete my work now I require to be able to debug on both the new and the old phone, the old one being a Samsung Gamaxy J5 2016 with Android 7.1.1.

    The error I get now in Xamarin Diagnostics is

    [E:]:                     Index (zero based) must be greater than or equal to zero and less than the size of the argument list.  
    System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.  
       at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)  
       at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)  
       at System.String.Format(String format, Object[] args)  
       at Mono.AndroidTools.AndroidLogger.LogError(String task, String format, Object[] args) in D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\AndroidLogger.cs:line 63  
       at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass118_0.<RunShellCommandAsync>b__0() in D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 1012  
    [D:RunShellCommand]:      dbb6c608 setprop "debug.mono.extra" ""  
    -- Start SetProperty - 12/02/2022 13:15:16 (148.7124ms) --  
    [INPUT] setprop "debug.mono.extra" ""  
    [OUTPUT]  
      
    -- End SetProperty --  
    [D:RunShellCommand]:      dbb6c608 am force-stop com.bshg.iservice5.droid  
    -- Start ForceStop - 12/02/2022 13:15:16 (1794.4007ms) --  
    [INPUT] am force-stop com.bshg.iservice5.droid  
    [OUTPUT]  
      
    -- End ForceStop --  
    

    The app gets installed on the phone, I can run it and test any changes by adding log entries that I can remove afterwards to see what is happening, but debugging would be so much easier and less time consuming.

    On the phone I have the unlock from OEM option on and USB debugging toggled on. I don't see any other related developer options to change.


  3. Graham McKechnie 316 Reputation points
    2022-12-03T20:45:48.9+00:00

    I don't think it is possible to debug on some older phones. I've not been able to debug on an old Samsung Tab A running 7.0 for maybe 2 years. I can't remember what was the last version of VS that I could debug on the Tab A. I can only deploy release builds to devices that I can't debug on. Why do you need to actually debug on that device? If a release runs on it what is the problem?


  4. Graham McKechnie 316 Reputation points
    2022-12-05T22:08:13.753+00:00

    @Foteini Verdou

    Out of curiosity, I tried again to debug on my old Samsung Tab A. It failed with the following

    Found device: 2a3ee81a22bb42a6  
    Installing Package com.companyname.navigationgraph7net7  
    Installed Package com.companyname.navigationgraph7net7. [87799ms]  
    XA0137: The 'run-as' command failed with 'run-as: Could not set capabilities: Operation not permitted  
    '.  
    Fast Deployment is not currently supported on this device.  
    Please file an issue with the exact error message using the 'Help->Send Feedback->Report a Problem' menu item in Visual Studio  
    or 'Help->Report a Problem' in Visual Studio for Mac.  
    Please set the 'EmbedAssembliesIntoApk' MSBuild property to 'true' to disable Fast Deployment in the Visual Studio project property pages, or edit the project file in a text editor.  
    Done executing task "FastDeploy" -- FAILED.  
    Done building target "_Upload" in project "NavigationGraph7Net7.csproj" -- FAILED.  
    Done building project "NavigationGraph7Net7.csproj" -- FAILED.  
    Build FAILED.  
    1>Deployment failed to Samsung SM-T350.  
    1>Deploy failed  
    ========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========  
    ========== Elapsed 01:34.561 ==========  
    ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========  
    ========== Elapsed 01:34.561 ==========  
    

    That was similar to what I used to get. If I then change to a release build the app installs and runs fine on that device.

    I then tested with Fast Deployment disabled by adding the following to the .csprog file

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">  
       <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>  
    </PropertyGroup>  
    

    I could then debug normally, hitting breakpoints, stepping etc. However, the deployment time went way up. You'd need a lot of patience to work all day with fast deployment turned off. I'm not sure if I turned off fast deployment when I tried last time so I can't confirm, but I presume I did at least try it.

    The other difference is that the particular app I tried it with has been converted to net7.0-android, so I can't confirm that it would work with a typical xamarin.android app. I'm using VS 2022 17.5.0 Preview 1.0

    0 comments No comments