Press F5, then wait a few seconds after project launches,
Uninstall the app from your device after stopping debugging session
The application will build successfully (with fast debugging on), and launch successfully, and allow me to debug.
It builds the project completely, then just stops, and warns you that fast deployment/debugging is not supported on this version of the device. Once you disable that, the project continues to build properly, then just stops. It doesn't even go into debugging mode. You can get this error by showing output from debug in the output tab, after the project is built.
> am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "Application.TSC/crc64c9abd8727b8dabd7.MainActivity"
> Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=Application.TSC/crc64c9abd8727b8dabd7.MainActivity }
Error type 3
Error: Activity class {Application.TSC/crc64c9abd8727b8dabd7.MainActivity} does not exist.
The next output will be from the build tab, but there are to many characters, so look at it in paste.rs instead.
The attached file is a download for the msbuild.binlog file. Download it here
@YJH16120
We will need a full diagnostic log of the issue please. Normal verbosity will not contain the kind f diagnostic data we need.
The easiest way to get that data is to run the following from a Developer command prompt after you have removed the app from the device.
msbuild YouAndroidApp.csproj /restore /t:Install /v:diag
This will produce an msbuild.binlog file which you can compress the log file and attach it to this issue.
We have a task which specifically detects this kind of situation, so it would be good to know why it is not working in your case.
I just need to open either powershell or CMD as an administrator then just use the command you mentioned correct? @dellis1972
@YJH16120 you visual studio installation will have a short cut for a "Developer Command Prompt" [1].
Start that. Then navigate to your project directory so you can run the command
msbuild YourAndroidApp.csproj /restore /t:Install /v:diag
You'll need to replace the YourAndroidApp.csproj with the actual name of your Android csproj.
[1] https://docs.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2019#start-the-shell-from-inside-visual-studio
@dellis1972 This is the error I got when I executed this command:
msbuild .\MobileApplication.csproj /restore /t:Install /v:diag
"C:\Users\YAP JIA HONG\Desktop\MobileApplication\MobileApplication\MobileApplication.csproj" (Install target) (1:7) ->
C:\Users\YAP JIA HONG\Desktop\MobileApplication\MobileApplication\MobileApplication.csproj : error MSB4057: The targe
t "Install" does not exist in the project.
Also I'm not sure if I should make a new issue because I am unsure whether or not this is related to my current issue, but I cannot download the apk produced by the app. The apk can be produced, I've also signed it and followed the necessary steps in the docs provided by Microsoft.
But when I go and download the contents of the apk file a warning shows up saying something along the lines of
This app is blocked by Play Protect
Play Protect doesn't recognize this app's developer, and can be unsafe.
I have never had this issue before. The notification also gives me an option to download it anyways, and I clicked that. But it still didn't download it.
The target "Install" does not exist in the project.
Did you run the command against the Android project? You can't run it against a netstandard project (like Xamarin.Forms).
The target "Install" does not exist in the project.
Did you run the command against the Android project? You can't run it against a netstandard project (like Xamarin.Forms).
I don't think so, let me try again.
The command has been ran successfully, and it has succeeded but I have no idea where the msbuild.binlog file is
@YJH16120 sorry I forgot to add the required /bl argument
msbuild YouAndroidApp.csproj /restore /t:Install /v:diag /bl
@dellis1972 I have updated the Log File section of the issue, and now it is a download to a rar file that contains the msbuild.binlog file, it's also available here.
I have updated the issue/first comment. After doing some more testing.
With that new info we will need a more detailed log I'm afraid
msbuild YouAndroidApp.csproj /restore /t:Install /v:diag /bl /p:_FastDeploymentDiagnosticLogging=true
The log you upload must be from a build which has the error in it.
Can you compress the resulting msbuild.binlog files then drag and drop that file into the comment section here so it can be directly attached to this issue.
I cannot use external file hosting sites (like mediafire) to get data.
I cannot use external file hosting sites (like mediafire) to get data.
Then here is the attached msbuild.binlog file. I unfortunately no longer have the original project with me as I've deleted it before, and created a fresh one to attempt to solve the issue. So the msbuild you're getting is the one I've recovered from the recycle bin, which is also the latest instance of the project at that time.
I'm not sure if it's a valid solution but I can go back into my commit history in the repo hosting my project before everything was overridden, and manually copy the files over before it was completely overridden.
Update 1:
I managed to get the project from before errors started, and I remember the steps I took, to cause the error. I'll update it with the msbuild.binlog file from before, and after.
@dellis1972 I realized that it's not an error, at least not in a traditional sense. This is the "error" that I got.

And I think that's why there isn't actually an error that's showing in the msbuild.binlog file.
@YJH16120
The error in the msbuild log file you updates had this error
error XA0010: No available device.
This is usually raised when adb reports it does not have any devices attached. If you had a device plugged in when you got this log I would suggest checking your usb cable or trying a different cable. I have had issues in the past where a bad usb cable would cause the device to drop its connection.
It also appears in that log file that the upload flag was not present so it looks like either a clean build or the DetectIfAppWasUninstalled did its job and deleted the upload flag to force a re-install.
The error about launching the application is expected if the apk was not installed. If you get that error again, what you can do is change the output window to show the Build log (rather than Debug) and that will have the logs for the deployment.
But in order to get the data we need you will need to put the following in the Debug section of your csproj.
<_FastDeploymentDiagnosticLogging>true</_FastDeploymentDiagnosticLogging>
This will allow us to capture more detailed diagnostics on what is happening.
Once you have that data save it to a file and again attach it to this issue so we can take a look.
error XA0010: No available device.
And as for this, I think you can ignore it, because when I plugged my phone in, the error disappears but the warnings remain. If you don't want me to ignore it, I'll go ahead and update the msbuild.binlog file that I'll attach to this comment.
It also appears in that log file that the upload flag was not present so it looks like either a clean build or the
DetectIfAppWasUninstalleddid its job and deleted the upload flag to force a re-install.
Do I need to worry about this part?
And as for this
<_FastDeploymentDiagnosticLogging>true
I've set it, and here is the attached msbuild.binlog file, the file is also from a point in time in the commit history of the repo, so some information may be different.
Update:
I realized I didn't actually do this step
<_FastDeploymentDiagnosticLogging>true
Here is the correct msbuild.binlog file:
msbuild.zip
@YJH16120
Thanks for the new log. Unfortunately it still contains the error
error XA0010: No available device.
The problem is with that error we are not going to get the error you reported which is
It builds the project completely, then just stops, and warns you that fast deployment/debugging is not supported on this version of the device.
We need a build log with the _FastDeploymentDiagnosticLogging property enabled which shows the error about fast deployment not being supported. The error codes will be something like XA0130 or XA0131.
I'll go ahead and produce another binlog file, with the device plugged in this time.
Here is the binlog file.
msbuild.zip
@YJH16120
Again thank you for the log. But it does not contain the error you mentioned (or any error).
I suspect because you disabled fast deployment to work around the issue.
So can we try this again please?
msbuild YouAndroidApp.csproj /restore /t:Install /v:diag /bl /p:_FastDeploymentDiagnosticLogging=true /p:EmbedAssembliesIntoApk=false
This new command line will override your project settings and port EmbedAssembliesIntoApk to be false.
So can we try this again please?
Done: msbuild.zip
There is one thing I should mention. I recently found a fix: I had to create a new project, copy and paste all the code and it just works fine. Like nothing ever happened. However, when I delete the instance of the mobile app that I got through USB debugging. The error returns. But if I repeat my steps, and do not delete the instance of the mobile app, everything works perfectly fine.
@YJH16120
I'm really sorry but that log still does not contain the error you reported?
It shows a successful fast deployment. There is no error about the Fast Deployment system not being supported and it looks like the app was installed ok. All the files were fast deployed to the device.
But I assure you, the instance of the application does not show up. I will remain in whatever screen I'm on at the time.
@YJH16120
Ok. So it seems that the app installs fine but then does not run unless you start it manually.
So lets get a bit more information.
From an Adb Command Prompt can you run the following command while the application is installed and running
adb shell ps -A
The Adb Command Prompt can be found in Visual Studio under Tools->Android->Android Adb Command Prompt.
Can you also post the contents of the following file obj\Debug\android\AndroidManifest.xml. Note the path is important here, it is the location of the final AndroidManifest.xml file that ends up in the apk. The one in Properties will not contain the data I need.
@dellis1972
From an Adb Command Prompt can you run the following command while the application is installed and running
I cannot install the application. When I create an apk then send it over to my phone, it says "app not installed." even though I have disabled Play Protect.
Here is a link to a video(You can click the gear at the bottom right to increase quality) showing you that I cannot go into debugging mode, which also means that I cannot run the application. It does, however, work on an emulator which won't do because I need to perform operations with a bluetooth device that requires the app to work on a physical android device.
Can you post the contents of the following file obj\Debug\110\android\AndroidManifest.xml. Note the path is important here, it is the location of the final AndroidManifest.xml file that ends up in the apk. The one in Properties will not contain the data I need.
Can you post the contents of the following file objDebug\110\android\AndroidManifest.xml
Done
AndroidManifest.zip
Ok so the MainActivity the IDE is trying to start exists in that AndroidManfiest.xml.
Looking back at the log from https://github.com/xamarin/xamarin-android/issues/5759#issuecomment-804870979. It seems to be from a completely different app? com.MobileApp not PictureApp.jiahong.
However this log https://github.com/xamarin/xamarin-android/issues/5759#issuecomment-804527074 was for PictureApp.jiahong. And it showed the app being installed ok.
So lets try this. From the Developer Command Prompt do the following
cd C:\Users\YAP JIA HONG\Documents\playground\app\App1\App1.Android\Install commandmsbuild App1.Android.csproj /restore /t:Install /bl:install.binlog /p:_FastDeploymentDiagnosticLogging=true /p:EmbedAssembliesIntoApk=false
_Run command msbuild App1.Android.csproj /restore /t:_Run /bl:run.binlog /p:_FastDeploymentDiagnosticLogging=true /p:EmbedAssembliesIntoApk=false
This is really confusing, the app appears to install and the manifest contains the right information, so I don't know how it is not finding it.
Looking back at the log from #5759 (comment). It seems to be from a completely different app? com.MobileApp not PictureApp.jiahong.
That's because it is, sorry about that. Anyway here are the requested files: install.zip, run.zip
@YJH16120 Thanks, that last set had the XA0130 error which you reported.
From the 'Tools->Android->Adb Command Prompt' in Visual studio can you now run after running the install.
so run
msbuild App1.Android.csproj /restore /t:Install /bl:install.binlog /p:_FastDeploymentDiagnosticLogging=true /p:EmbedAssembliesIntoApk=false
from the Developer Command Prompt as before then run
adb shell "run-as" "PictureApp.jiahong" "mkdir" "-p" "files/.__tools__"
From the 'Tools->Android->Adb Command Prompt'.
Then post what the result was. I need to find out what error is being reported.
adb shell "run-as" "PictureApp.jiahong" "mkdir" "-p" "files/.__tools__"
I can't run this, because I don't have that folder.
@YJH16120
The command is one of the many which we run during the fast deployment process. It should create the files/.__tools__ folder in the application internal directory on the device. The folder does not have to exist on your machine.
The adb shell is running a command prompt on the device, the run-as part is making sure we run as the app you installed.
This is what shows up when I run the command though
C:\Program Files (x86)\Android\android-sdk>adb shell "run-as" "PictureApp.jiahong" "mkdir" "-p" "files/.tools"
run-as: couldn't stat /data/user/0/PictureApp.jiahong: No such file or directory
@YJH16120
ok thanks. It appears that the app is installed but not for the user 0..
Do you run your device with Multi User enabled?
can you provide the results in the 'Tools->Android->Adb Command Prompt' for the following command
adb shell pm list users
@dellis1972
This is what I got
Users:
UserInfo{0:Owner:13} running
UserInfo{10:PrivateSpace:2000010} running
The other thing to try is to to change android:installLocation="preferExternal" in the Properties\AndroidManifest.xml to android:installLocation="auto"
I've done that, do I re-run adb shell pm list users?
So are you trying to run the app under the PrivateSpace user?
I have seen issues with the install where if the app is installed under another user account it will fail to update.
So it might be worth changing to the other user and uninstalling the app (if it is installed).
The only account on my phone is mine. I didn't even know you can have two accounts.
Update:
I was digging through settings, and the such and found out I had a PrivateSpace. I think I set it up a long time ago, but forgot about it. But yeah, there were like 20 instances of the app. I deleted them all.
Hmm Try removing that Private Space account (if you can) and see if that helps?
The error you are hitting is defined in the google run-as app here https://github.com/aosp-mirror/platform_system_core/blob/34a0e57a257f0081c672c9be0e87230762e677ca/run-as/run-as.cpp#L76.
I've never seen that error get raised before. To what ever device you are using seems to differ from the standard android os. Which manufacturer is it? Perhaps they have made some alterations. It suggests something is not quite right with the device file structure.
Does the app install and launch if you turn off 'Fast Deployment'?
@dellis1972
It works now. After I deleted all instances, the app now deploys successfully without any issues.
@YJH16120
awesome. I think I will add some additional checks to check for that particular error and not a solution in the build output.
Thanks for getting me all the data. This will help us improve the reliability of the new system
Thanks for getting me all the data. This will help us improve the reliability of the new system
Welcome :D Thanks for the help. Been stuck on this for days.