dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.92k stars 526 forks source link

failure to deploy to physical device #5532

Closed fbd-ss closed 2 years ago

fbd-ss commented 3 years ago

After i installed xf 5.0.i can no longer deploy to physical device ( Note 9 Api 29 ) rolled back to 4.8 problem still persists. Only for physical devices, emulator deploys ok. Doesn't mater what project i open the result is the same. It hangs here "Detecting installed packages...". Repaired VS ( Community 2019, Version 16.8.4 ) but still no change.

PureWeen commented 3 years ago

@fbd-ss can you attach your build logs https://docs.microsoft.com/en-us/visualstudio/ide/how-to-view-save-and-configure-build-log-files?view=vs-2019#to-change-the-amount-of-information-included-in-the-build-log

fbd-ss commented 3 years ago

Output-Build.txt

this is from the master detail demo sample

Cheers.

jonathanpeppers commented 3 years ago

I don't see the Install target running in your log, did you deploy the app?

You might try command-line with something like:

> "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Bin\MSBuild.exe" MasterDetailPageNavigation.Droid.csproj -t:Clean,Install -bl

This will Clean, Build, Deploy and save a detailed msbuild.binlog file you can zip and upload here.

You might also check if adb sees the device with:

> "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" devices

This should print the name of the device/emulator you expect.

Let us know, thanks!

fbd-ss commented 3 years ago

Output-Build.txt

Sorry, I couldnt get the binary log to work, will have to do a bit of research on that one. The log file was deployed to device.

adb can see both physical and emulator

Cheers

jonathanpeppers commented 3 years ago

Sorry, I'm still not seeing the deploy step happening in this log file. There should be Install and SignAndroidPackage targets running.

What is the actual error message you are getting during deploy? Is that in the log?

fbd-ss commented 3 years ago

Hey Jonathan very last line of the log, not an error but hangs indefinitely "2>Waiting for runtime checks to complete"

jonathanpeppers commented 3 years ago

@fbd-ss if you reboot your PC does it fix the problem?

Looking into similar comments: https://stackoverflow.com/questions/50345987/xamarin-waiting-for-runtime-checks-to-complete-and-vs-emulator

It seems like others are pointing fingers at either the emulator or adb needing to be restarted.

I didn't actually find the text Waiting for runtime checks to complete in any Xamarin codebases...

fbd-ss commented 3 years ago

Hey, Restarting was the first thing i tried, even repaired vs ( reluctantly ), thought something funky might be going on there but no luck, i think its related to adb but have no idea what im doing as far as adb goes. Once and only once it flashed to the phone when in the adb prompt i ran something like ( while deploying ) "abd kill-server && server-restart" which i found on the net. But that only worked once. What is adb part of is there a way to reinstall just that component.

All other adb functions seem to work, ie can see device, logcat, device monitor etc is working

Cheers for your time with this. Steve

fbd-ss commented 3 years ago

reinstalled sdks, still no change. the post you sent was dealing with emulators - i dont have an issue with emulators only with physical devices.

this the last few lines from the "Xamarin output" ( output window )

Xamarin - 16.8.000.261-d16-8+bb99248 Successfully connected to Local Broker Starting IDB Local Agent... Checking IDB.Local 16.8.000.261 installation... Starting IDB.Local 16.8.000.261 in port 58776... IDB.Local 16.8.000.261 started successfully Successfully started IDB Local Agent iTunes has not been found. Please ensure to have a valid iTunes installation in order to communicate with Apple devices in Windows

dont know why its looking for ios because i have the IOS project unloaded.

this the last few lines from the "Xamarin diagnostics output" ( output window )

[I:]: Got new device list from adb with 2 devices [D:RunShellCommand]: 27785d370e017ece getprop [D:RunShellCommand]: emulator-5554 getprop [D:RunShellCommand]: 27785d370e017ece am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_29,fbd.iot.controller" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions"

this the last few lines from the "Build" set to minimal ( output window )

Build started... 1>------ Build started: Project: fbd.iot.controller.Android, Configuration: Debug Any CPU ------ 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3277: Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. 1> fbd.iot.controller.Android -> E:\fbd.iot.controller\src\presentation\fbd.iot.controller.Android\bin\Debug\fbd.iot.controller.Android.dll 2>Waiting for runtime checks to complete <<<<<<<< hangs after this

but its still working in some thread in some other universe because the project is still locked, ie i cant rename files or anything like that.

jonathanpeppers commented 3 years ago

Does the command complete if you run it manually?

> "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" shell am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_29,fbd.iot.controller" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions"

We've seen this command hang before, and rebooting the physical device has solved it in the past. What is the device and Android OS version?

We have reworked Fast Deployment in VS 16.9, to solve problems with the latest Android versions. In the next version of Xamarin.Android, it won't need to run am broadcast anymore. You could try installing the VS 16.9 Preview, to see if things fare any better. You can install the Preview side-by-side stable.

fbd-ss commented 3 years ago

this is what i got back from the command,

"Broadcasting: Intent { act=mono.android.intent.action.PACKAGE_VERSIONS flg=0x400000 cmp=Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions (has extras) }"

still no luck, even after reboot.

device: galaxy note9 (SM-N960F) version: android version 10

jonathanpeppers commented 3 years ago

Were you able to try the 16.9 preview?

fbd-ss commented 3 years ago

I just installed and tried it, 2019-3 actually deployed to device, or so it said, but it never actually ran on the device.

Samsung had a security update available so i installed that, and back in 2019, i tried it again. It took 10 minutes but got to the device. I redeployed a few more times straight away, now its working like it was a week ago.

I don't know what happened to cause it to work again.

Output-Debug2601-1.txt

lines 310 - 314 i don't remember ever seeing before.

jonathanpeppers commented 3 years ago

These messages are normal, you can ignore these:

Skipping native libs, not configured...
Skipping dexes, not configured...
Skipping resources, not configured...
Skipping typemaps, not configured...
Creating "obj\Debug\100\upload.flag" because "AlwaysCreate" was specified.

It sounds like you got it working by updating the device? Let us know if you hit the problem again, thanks.

fbd-ss commented 3 years ago

Thanks for your help.

fbd-ss commented 3 years ago

Well that didnt take too long to break again, It is caused by the debugger. The debugger crashed and hung VS for a while. Restarting pc, and device had no effect.

jonathanpeppers commented 3 years ago

So I wonder if uninstalling these packages on the device helps:

adb uninstall Mono.Android.DebugRuntime
adb uninstall Mono.Android.Platform.ApiLevel_28

You can also use the Settings app instead of the adb command. I would also uninstall your app, then try to deploy again.

fbd-ss commented 3 years ago

Just tried it, no change.

Originally i uninstalled then through the app settings on the device, do those commands do the same thing?

fbd-ss commented 3 years ago

Any other ideas, i'm a bit stuffed without testing on a real device. ie network connections

fbd-ss commented 3 years ago

Just tried android studio and rider, both could upload programs to device no worries.

16.9.0 Preview 3.0 is completely broken when trying to upload, it thinks it is debugging but nothing appears on the device.

fbd-ss commented 3 years ago

Is there any way i can roll back to an older version in community edition?, i can only see side by side older versions for professional and enterprise.

dellis1972 commented 3 years ago

@fbd-ss sorry you are still having issues. In order to help we would need full diagnostic build output. The easiest way to do this is to make sure your app is uninstalled from the device then run the following from a VS 2019 Preview 3.0 command prompt.

msbuild fbd.iot.controller.Android.csproj /restore /t:Install /bl /p:_FastDeploymentDiagnosticLogging=true

You will need to be in the same directory as fbd.iot.controller.Android.csproj This will produce an msbuild.binlog file which you can then zip up and attach to this issue. We can then take a look at what is happening during fast deployment.

Once you have that log file you can also try

msbuild fbd.iot.controller.Android.csproj /restore /t:_Run /bl

Which will attempt to run the application. Again attach the log file. (it will be named msbuild.binlog as well so you will need to rename the first one).

fbd-ss commented 3 years ago

Thanks Dellis, Could i use the non preview command ie 16.8.4, I just uninstalled pre-3

dellis1972 commented 3 years ago

Well if its still not working then sure logs from the 16.8.4 will also help, you can skip the /p:_FastDeploymentDiagnosticLogging=true argument though. That particular property is new and only available for pre-3.

I was hoping to get some data on why fast deployment is not working in pre-3 since that will be going into stable in a few weeks. So if you do get a chance to use it that would be great. I do understand you have work to do though so if you can't reinstall it don't worry :).

One other thing to try is to disable the "Use Shared Runtime" in your Project Settings. We have reports of it not working on API 30 devices. Thats one of the reasons we rewrote the fast deployment system for pre-3. While disabling the shared runtime will make the debug loop slower (it has to re-install the apk each time), it might be more reliable in your case.

fbd-ss commented 3 years ago

will put it back on in the morning,

have tried the shared runtime off as well as all the other stuff i've found on the net.

fbd-ss commented 3 years ago

logs attached, the project builds ok in 16.8.4 msbuild-restore.zip msbuild-run.zip

dellis1972 commented 3 years ago

@fbd-ss thanks for the logs. Can I ask if you had the problem device plugged in when you ran those commands? The logs contain a error XA0010: No available device. error.

fbd-ss commented 3 years ago

yes, and it was unlocked

dellis1972 commented 3 years ago

ah this is it

adb is not running. System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:5037

looks like adb is having a problem. Not entirely sure what might cause that. Virus scanner maybe, or firewall. @jonathanpeppers any ideas?

fbd-ss commented 3 years ago

no idea, it all chaged when i updated to xamarin 5.0, and its beed stuffed ever since. For all projects. Adb runs fine with emulator on 16.8. It seems something is killing adb on device, as i said before i got it to run once by killing adb in task manager, when it restarted by itself all was good. But that only worked once.

I dont know enough about adb. But the behavoiur is different between 16.8 and 16.9.

jonathanpeppers commented 3 years ago

This doesn't seem like it would be affected by the version of Visual Studio:

No connection could be made because the target machine actively refused it 127.0.0.1:5037

You could try killing adb:

> "C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe" kill-server

Then deploy again from Visual Studio to see if that solves anything.

You could also try uninstalling Platform-Tools and reinstalling it:

image

Or just check you have the latest version ^^

fbd-ss commented 3 years ago

Yup i already reinstalled platform tools.

Every time i kill adb it just pops ups again in task manager.

Ill try again.

fbd-ss commented 3 years ago

Uninstalled and reinstalled tools, still hangs see the attached file

Is there some sort of cache that adb uses that i can wipe after uninstalling after tools updated.zip

fbd-ss commented 3 years ago

hey guys, where did you find this "No connection could be made because the target machine actively refused it 127.0.0.1:5037"

dellis1972 commented 3 years ago

it was in the log files you sent. Here is an extract

Target "_GetPrimaryCpuAbi: (TargetId:233)" in file "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets" from project "E:\fbd.iot.controller\src\presentation\fbd.iot.controller.Android\fbd.iot.controller.Android.csproj" (target "_CheckInstantRunCondition" depends on it):
Using "GetPrimaryCpuAbi" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Build.Debugging.Tasks.dll".
Task "GetPrimaryCpuAbi" (TaskId:147)
  Task Parameter:AndroidPackage=fbd.iot.controller (TaskId:147)
  Task Parameter:DevicePropertyCache=obj\Debug\100\devices.cache (TaskId:147)
  adb is not running. System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:5037
     at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
     at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
     at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
     at Mono.AndroidTools.Adb.AdbClient.EndConnect(IAsyncResult asyncResult) in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbClient.cs:line 141
     at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
     at Mono.AndroidTools.AdbServer.<>c__DisplayClass9_0.<RunCommandWithMessage>b__0(Task t) in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AdbServer.cs:line 83
     at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
     at System.Threading.Tasks.Task.Execute()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Mono.AndroidTools.AdbServer.<GetDevices>d__17.MoveNext() in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AdbServer.cs:line 134
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
     at System.Threading.Tasks.Task`1.get_Result()
     at Xamarin.Android.Tasks.AndroidHelper.ParseTarget(String target, Action`1 logMessage, Action`2 logError, Boolean logErrors, IBuildEngine4 engine4) in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/Utilities/AndroidHelper.cs:line 53
  ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:5037
     at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
     at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
     at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
     at Mono.AndroidTools.Adb.AdbClient.EndConnect(IAsyncResult asyncResult) in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbClient.cs:line 141
     at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
     at Mono.AndroidTools.AdbServer.<>c__DisplayClass9_0.<RunCommandWithMessage>b__0(Task t) in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AdbServer.cs:line 83
     at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()
     at System.Threading.Tasks.Task.Execute()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Mono.AndroidTools.AdbServer.<GetDevices>d__17.MoveNext() in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/AdbServer.cs:line 134
  ---> (Inner Exception #0) System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:5037
     at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
     at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
     at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
     at Mono.AndroidTools.Adb.AdbClient.EndConnect(IAsyncResult asyncResult) in /Users/builder/azdo/_work/278/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Adb/AdbClient.cs:line 141
     at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)<---
  <---
   (TaskId:147)
  No device found: AdbTarget="" (TaskId:147)
  Output Property: _DeviceSdkVersion=0 (TaskId:147)
Done executing task "GetPrimaryCpuAbi". (TaskId:147)
fbd-ss commented 3 years ago

Any idea how to fix it, I dont have this problem with Rider or Android studio with that device.

dellis1972 commented 3 years ago

@fbd-ss

I'm not entirely sure, this is a very odd situation. A few questions though.

Are both Visual Studio and Rider setup to use the same android SDK? When you are using Rider, are you using Xamarin within Rider or is this for a Java app?

Can you try the following

  1. Go into Visual studio and go to Tools->Android->Android Sdk Command Prompt
  2. type adb kill-server
  3. type adb connect :5037

what does that do?

Also when the device is connected (from the same command prompt) does adb devices show the device?

What Anti-virus / firewall software do you use? We have seen instances where this can cause issues, although it does not explain why it works for Android Studio.

fbd-ss commented 3 years ago

Hey, I have it running ( forever hopefully ).

I'm confident this is not a Anti-virus / firewall software issue.

If i had to guess, i would say that it is a msbuild issue, or what ever communicates with adb on the build side. Would be worth more investigation as it extremely limits development if relying on an actual device for app development.

Both rider and android studio were just running java apps. All i was trying to rule out is it wasn't the phone.

One thing that was consistent was when deploying and hanging on the first "Waiting for....", if the abd kill-server command was issued it would start again. Once it hung on the next "Waiting for...." event, and abd kill-server was issued again it would stop the build deploy process as coms had been lost.

The phone has always been available over adb from the command line. So i was pretty sure it was a communication between adb and whatever is on the build side.

So when the second hang occurred i ran any and all adb commands that wouldn't stop the build and finally it carried on and completed after a couple of minutes. I cant tell you which command triggered the 2 sides talking together, as i tried them all.

I would put 5 bucks on it being a command being issued by some sort of fire and forget messaging system not reaching its target, ie MessagingCentre ( should be banned from all programming languages in my opinion ). I know how microsoft loves throwing around magic strings.

Anyhoo ill let you know if it is still working in a couple of days,

A couple of good things came out of this, I learnt a lot about adb, and discovered your binary logs.

fbd-ss commented 3 years ago

I guess yesterday was sheer luck, back to status quo.

Its giving me this a lot when building now "The build was cancelled because another Xamarin operation is running. Please try again in a moment."

fbd-ss commented 3 years ago

Don't suppose anyone wants to do a remote session and have a look for themselves to see whats going on, before i put a sledge hammer through my monitor.

dellis1972 commented 3 years ago

I've been doing some more research on adb. The code we have in MSbuild to connect to adb is just a Standard TCP Network connection. This is the same as the adb.exe client uses . So what happens is when you run adb from the command line it looks for an adbd process then if it doesn't find one it will start one (i.e start-server). By default this should start a TCP server on port 5037. Which will then allow the adb client to connect to it. The connection refused error seems to indicate that the adbd process is not running or it is running but not using the default port of 5037.

There is an environment variable ANDROID_ADB_SERVER_PORT which can be set to force the port which should be used. In theory it defaults to 5037, but I am wondering if android studio or rider is setting a different port?

Perhaps try setting ANDROID_ADB_SERVER_PORT to be another port in your system environment settings? See if that helps?

Also apparently setting ADB_TRACE=all as an environment variable might produce some additional logging.

dellis1972 commented 3 years ago

BTW I'm running platform tools version 30.0.2. I wonder if it is worth perhaps downgrading to that?

fbd-ss commented 3 years ago

Thanks Dellis, It started working again, Not sure why. I opened the project in prev 3 and deployed(debug). It actually built and loaded the app on the phone and the app was in a usable state, it was running solo ( no debugging ). On the other hand vs thought it was debugging an app, so i set a break point that should have been hit on load and it never got hit. I Think the debugger has got Tourette's, at the very minimum a mild case of schizophrenia.

After i restarted the app back in 16.8 after a few attempts it started working again. So being slightly mad i tried to break it again by setting to different port in adb. But couldn't manage to break it.

Ive set the env vars so well see what happens.

fbd-ss commented 3 years ago

On a side note, do you have any idea how to mute Mono so i dont get all the following garbage in the debug output.

02-03 13:04:07.509 D/Mono (19589): Searching for 'sk_compatpaint_delete'. 02-03 13:04:07.509 D/Mono (19589): Probing 'sk_compatpaint_delete'. 02-03 13:04:07.509 D/Mono (19589): Found as 'sk_compatpaint_delete'. 02-03 13:04:07.511 D/Mono (19589): DllImport searching in: 'libSkiaSharp.so' ('./libSkiaSharp.so'). 02-03 13:04:07.512 D/Mono (19589): Searching for 'sk_fontstyle_delete'. 02-03 13:04:07.512 D/Mono (19589): Probing 'sk_fontstyle_delete'. 02-03 13:04:07.512 D/Mono (19589): Found as 'sk_fontstyle_delete'. etc

Not that i care its there but i have to wait 30 seconds while it rambles on before the app loads

dellis1972 commented 3 years ago

@fbd-ss you can alter the MONO_LOG_MASK (which defaults to "all") to change those outputs.

Easiest way is to add a new file environment.txt to your android project. Give it a Build Action of AndroidEnvironment and give it the following contents

MONO_LOG_MASK=”dll,cfg”

This will turn off everything except logging of loading assemblies and config files.

paulelong commented 3 years ago

@jonathanpeppers @dellis1972 I believe I have the same problem. When I launch the app from Microsoft Visual Studio Community 2019 Version 16.8.5, it gets stuck at "Detecting installed packages...". I'm using a Galaxy S8 which I've been creating apps for the last few years. When my app that I've been successfully deploying for weeks now stopped working I created a new app from the xamarin template, and this also fails. But I'm able to deploy to the emulator. The other interesting point is I am also able to deploy to my Galaxy Tab S7. I also have a new Galaxy S21 that is also failing, though with a different error. Perhaps that's not relevant.

I believe this happened after upgrading to 16.8.4, but I'm not certain. I have since upgraded to 16.8.5, hoping that would resolve this frustrating problem. I've tried upgrading the Android SDKs as well.

I've tried many off the tshooting steps above, but will to try what ever you need. Also if you think I should open a new issue, I can do that. I've attached the two logs mentioned above from running the msbuild commands.

Thanks, Paul

DeplayXamTest.Android.zip

dellis1972 commented 3 years ago

I had another thought. The 16.8.5 version of Xamarin.Android is still using the old fast deployment system (we rewrote it for 16.9.x). The "Detecting installed packages..." is waiting on the results of an Android broadcast to return the list of the packages and the versions. It is possible that this broadcast is just not returning, we have seen this before.

I would suggest turning off the use of the Shared Runtime in your project settings. That should in theory mean that the broadcast is never used and the app will just be installed as normal. It will result in slower install times since the full apk will need to be installed but it might help work around the issue.

the other option is to install VS2019 d16.9 P4 (which can be installed side by side) and see if that helps?

paulelong commented 3 years ago

I noticed a bunch of Xamarin API items in the Apps list, so I uninstalled those but no difference, still gets stuck with ""Detecting installed packages..."

I had already had Shared Runtime disabled in project settings, but tried again to make sure and still the same error.

I install VS2019 16.9 P4, and it still gets stuck, but it has a different message. The only two I see are "Forwarding debugger port 8900" and "Detecting existing process". But it never goes further than this.

To add to this, when I stop the process is says "The debugger was unable to terminate one or more processes: [] Mono: The debugger is still attaching to the process or the process is not currently executing the type of code selected for debugging" The debugger may be unstable now. It is recommend that you save all files and exit."

I also tried to create a new project from scratch in VS2019 16.9 P4, and it also fails the same way.

fbd-ss commented 3 years ago

@dellis, Shared Runtime or unticking fast deployment has never made a difference.

the 16.9.4 still has the issue of deploying to device but is never actually debugging, ie nothing comes up on the phone, and opening the app on the phone just crashes the app.

this is the results of deployment with 16.9.4,

[D:KillProcessIfRunningAndWaitForExit]: Checking whether app fbd.iot.controller is running D:RunShellCommand: 27785d370e017ece ps -A [D:KillProcessIfRunningAndWaitForExit]: App was not running, skipping kill [D:GetLogCat]: logcat -v time D:RunShellCommand: 27785d370e017ece logcat -v time D:RunShellCommand: 27785d370e017ece ps -A D:RunShellCommand: 27785d370e017ece date +%s D:RunShellCommand: 27785d370e017ece setprop "debug.mono.extra" "debug=127.0.0.1:8902,timeout=1613075858,loglevel=0,server=y" D:RunShellCommand: 27785d370e017ece getprop

D:RunShellCommand: 27785d370e017ece am broadcast -a "mono.android.intent.action.EXTERNAL_STORAGE_DIRECTORY" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.ExternalStorageDirectory" D:RunShellCommand: 27785d370e017ece ps -A D:RunShellCommand: 27785d370e017ece ps -A D:RunShellCommand: 27785d370e017ece ps -A D:RunShellCommand: 27785d370e017ece ps -A D:RunShellCommand: 27785d370e017ece ps -A D:RunShellCommand: 27785d370e017ece ps -A

where "D:RunShellCommand: 27785d370e017ece ps -A", just keeps repeating forever.

fbd-ss commented 3 years ago

I did find this in the Xamarin diagnostics window,

Xamarin - 16.8.000.261-d16-8+bb99248 Successfully connected to Local Broker Starting IDB Local Agent... Checking IDB.Local 16.8.000.261 installation... Starting IDB.Local 16.8.000.261 in port 56083... IDB.Local 16.8.000.261 started successfully Successfully started IDB Local Agent iTunes has not been found. Please ensure to have a valid iTunes installation in order to communicate with Apple devices in Windows No Android SDK instance matching the 'C:\Program Files (x86)\Android\android-sdk' path Android component "tools" is obsolete, please install "cmdline-tools" Trying to fallback to "tools"... File 'C:\Program Files (x86)\Android\android-sdk\cmdline-tools\android.bat' not found for 'Android SDK Core' File 'C:\Program Files (x86)\Android\android-sdk\cmdline-tools\mksdcard.exe' not found for 'Android SDK Core' File 'C:\Program Files (x86)\Android\android-sdk\cmdline-tools\emulator.exe' not found for 'Android SDK Core'

even though cmdline-tools is installed.

What is the correct way to setup/check sdk paths are correct.