The referenced component Mono.Android could not be found - c#

I have the same problem...pls help me...
I just installed the Xamarin and want to use vs2015 . When I create a new Blank App (Android) and I’m getting the following errors. How can I fix this? I reinstalled vs2015 and reinstalled Xamarin but I’m still getting the errors.
The referenced component ‘Mono.Android’ could not be found.
The referenced component ‘mscorlib’ could not be found.
The referenced component ‘System’ could not be found.
The referenced component ‘System.Core’ could not be found.
The referenced component ‘System.Xml’ could not be found.
The referenced component ‘System.Xml.Linq’ could not be found.

For me, I just ran into this trying to build a project pulled from TFS on a new VS 2015 Update 2 install. Not sure what exactly fixed it but this is what I did:
Download Android API 23 and 22 SDK from the SDK Manager and also updated all other items in SDK Manager (had to close and open it twice to get it totally up-to-date).
Nuget Restore packages (this did not fully fix it).
Followed these instructions where you go into all .csproj file in the solution and remove all mentions of nuget. Also do this in the solution file, but mine had nothing.
Use Package Console and run Update-Package -Reinstall (of if you know these package were building just fine before, I ran ``Update-Package -Reinstall -IgnoreDependencies`) and choose the project if you want.
Still had a couple errors from the Android Resource Designer file so did a build and everything was right in the world again.

For me it was a Mono.Android.dll version issue.
I removed the reference, and added a reference to the right version.

These errors most likely point to an installation with missing pieces (or a corrupt install). Try reinstalling Xamarin (again, yes) with admin privileges if you haven't done so already.
If you check your version information via "Help -> About Microsoft Visual Studio -> Copy Info [button]" and Xamarin isn't listed in the bottom, then your install didn't go through correctly.
Additionally, can you double check you have the Android SDK installed? Open up the start menu and type Android SDK Manager. Run it and make sure you've downloaded the build tools and one of the recent API levels.

For me i had to remove the pcl(portable class library) from the solution then added it back then the issue was resolved.

Related

Cannot find assembly Mono.Android when attempting to archive a Xamarin app for publishing

I had to do some work on a Xamarin project I didn't create that is currently in production. I can build the app in Debug and Release on both Android and iPhone, as can anyone else who clones the repo. However, no one on my team has been able to successfully archive the app for publishing. Everyone gets the same error: Could not resolve this reference. Could not locate the assembly "Mono.Android". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Question 1: Where exactly should Mono.Android exist on disk?
Could not locate the assembly "Mono.Android". Check to make sure the assembly exists on disk
In the projects .Droid folder in the references folder Mono.Android does exist but apparently this isn't enough. Where else should it exist if this is not the only place?
On Windows people say to look in something like C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid{VERSION NUMBER}\Mono.Android.dll but I am on Mac, so where might this be instead?
Question 2: Why exactly am I getting this error in the first place?
Whatever the problem is I don't understand why it would trigger when trying to archive only the .IOS project. As far as I know this shouldn't have anything to do with Mono.Android. I feel like I should only be getting this error when I try to archive the .Droid project.
Question 3: What solutions are there to this?
Requires minimum Android version: 6 (API level 23)
Target Android version: 9.0 (API level 28)
Everyone on the team is using VS for Mac.
I have confirmed that I have Android 9 Pie installed and with all it's packages. I have attempted to archive for publishing on both Visual Studio for Mac 2019 and 2022 but got the same result for each. I have had others on the team attempt the same.
I have attempted to re-reference Mono.Android but when I try to add a reference and I scroll down to Mono.Android the version is 0.0.0.0. Why would that be?
What am I missing and how do I get it?
If you need any additional information please ask and I'll do my best to share.
I finally successfully deployed the app. I found a hardcoded path to Mono.Android in the Droid project csproj file. I removed this and the Mono.Android error stopped, but I was still getting similar errors so this is what happened:
I believe that the app was originally developed in VS for Mac 2017 and used whatever Xamarin package versions came with whatever version of VS for Mac 2017 the app was developed in. I am using an M1 Mac and cannot install VS for Mac 2017 or a lot of the packages that I needed. So what I did was moved to VS for Mac 2022 and upgraded all Xamarin packages and then fixed the errors that arose from that.
Once all packages were upgraded the app still would not deploy properly so I downloaded Transporter and used that to deploy the app which was very easy.
I hope this helps someone in the future.

System namespaces missing MonoDevelop on fresh install

I am wondering if anyone can help me, I did a fresh install of MonoDevelop on a fresh install of Ubuntu 18.04.2 LTS with .NET Core 2.2 installed (everything updated), then followed the instructions layed out at Mono Download Offical. I have no errors or warnings during installation.
When I create any type of project or open one, all the system namespaces are missing?
I have checked here:
And
When I build / Clean any project I get:
/home/ant/.cache/MonoDevelop/7.0/MSBuild/27259_1/Microsoft.CSharp.CurrentVersion.targets(5,5):
Error MSB4019: The imported project
"/home/ant/.cache/MonoDevelop/7.0/MSBuild/27259_1//Microsoft.CSharp.Core.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk. (MSB4019) (sadsad)
Error
I solved it temporarily:
I went to the Namespace/Class options and under Run - Default - Advanced I selected Execute in .NET runtime -> Mono 5.20.1.34
It fixes the problem until i restart Monodevelop.
I'm having this problem since this morning, even after a fresh reinstall.
I am using Ubuntu MATE 18.04
This was a problem with mono its self, mono updated and was using a different version of MsBuild which the IDE could not use/understand. So I pulled the preview repository, as they added a fix there.
To fix:
purge monodevelop and mono-devel (with others) and install from here Preview - Stable until they patch the normal repository
I had the same problem with Monodevelop under Raspian (Rasberry3)
I believe I can now offer a viable solution:
It's just a setting that has to be done in Monodevelop before you start a new project:
Search under the settings, create and disable the line "create with MSBuild instead of xbuild".
After that all new projects will be recognized without errors.
For old projects the procedure is similar:
but there you should delete the folder ".vs" in the project folder first (better make a backup copy first! ;) ).
Start Monodevelop. Check that the settings are as described above.
Then open the project in Monodelop.
When you open the project, it will be reinitialized and can then be edited and compiled without any problems.

How to clone a Xamarin Project and have it build right away

I am working on a project on my laptop, and am switching laptops. It is a Xamarin Android project with C#. It is source controlled onto visual studio online / devops using the Git option. When I clone my project onto my new laptop. My project is not building. Some projects aren't loading and some of my references have errors next to them.
I think to get it working requires some necessary steps. Please tell me if any of this should not be necessary.
(1) Open Visual Studio Installer and Modify in order to add Mobile Development and .Net so that Xamarin is installed.
(2) Tools > Android > Android SDK Manager > Checkmark necessary SDKs (aka android Lollipop, etc). (If these are failing, then right click on visual studio icon to "Run as Administrator" when initially opening.
This third step is whats bothering me:
(3) Clean Solution and Rebuild. And magically every dependency and every necessary anything is automatically installed/etc.. but not true.
Instead...
Some references in your projects will have a yellow triangle icon. Go to Tools > Nuget Package Manager and when you select any of the Installed projects, there will NOT be a checkmark next to ANY projects.. weird.. but when you go to Update, and click on any needing an update, the checkmark will be there. If you select all and update, some of your yellow triangles will go away, but the checkmarks won't appear in Installed when clicking on a project and seeing which projects it is installed in on the right.
Is there some button or command I am supposed to run that will grab all the necessary dependencies for me? Instead of me having to dig around and still have a non working solution?
Can you give some examples of the error messages you are getting? Usually Project Load - Restore Nuget Packages - Clean & Rebuild works for me.
NuGet will download the packages available in the package manager. However it may happen that some packages where not installed through the sources available in the package manager or that those packages are not available anymore.
In order for all the projects to build correctly I believe the following order is necessary: (As OP, I downloaded and tried to build the project before checking to make sure I had Xamarin and the necessary SDKs, and once those were installed, it wouldn't fix the project without deleting and recloning)
(1) Do NOT clone your project from github/devops yet. Delete it if you have.
(2) Install Xamarin. Open Visual Studio Installer and Modify in order to add Mobile Development and .Net so that Xamarin is installed.
(3) Install necessary SDKs for Android OS version. Tools > Android > Android SDK Manager > Checkmark necessary SDKs (aka android Lollipop, etc). (If these are failing, then right click on visual studio icon to "Run as Administrator" when initially opening.
(4) Clone project from github/devops, and clean/build. Should work automatically.
(An aside: I feel like step 3 should also be automatic? It should know which ones I'm targeting and auto install those? Maybe it does, I'm not sure.)

VS 2015 w/ Xamarin: This item does not support previewing

I'm using Visual Studio 2015 with Xamarin 4.1.2.18 and CocosSharp PCL 1.6.2.
When I try to access the Properties of the Android project by clicking on the "Properties" item in the Solution Explorer, this error pops up:
If I also right click on the project itself and select "Properties", it displays "This item does not support previewing".
It should be opening up to this page:
I have (supposedly) the latest build and Update 3. I have reinstalled it 3 times now.
Normal uninstaller. Reinstalled... nothing, still broken.
Uninstall again with cmd: /uninstall /force, use registry cleaners, manually uninstall components from Control Panel, manually delete folders. Reinstall... still broken.
Finally, I searched around and found this: Microsoft Visual Studio Uninstaller. After I, again, performed all the steps of 2, I used this tool and it found 52 additional things to clean up. I thought I finally had fixed it. Nope. The properties thing is still broken.
I have tried running as administrator. Nope.
I have deleted the ComponentModelCache in local AppData. Nope.
I have deleted the .suo file. Nope.
I know it has nothing to do with the project files because we have all the files synced with Git and my friend can view the properties page fine on his computer.
Does anybody know how I can fix this?
Is there some way to gather more information on the error?
Any Visual Studio error logs?
Also, on an semi-unrelated note:
When I try to build the Android project, I get errors saying that the $(TargetFrameworkVersion) for my references/dependencies is v4.2 and the $(TargetFrameworkVersion) of my project is v2.3. I checked my TargetFrameworkVersion property in the .csproj file and it's v6.0!
So, something is seriously wrong with this build of Visual Studio or something.
I've been considering just installing Visual Studio on a VM just to be sure.
Solution:
In the Android SDK manager, I had Android 4.0 (API 14) downloaded. Once I switched to Android 4.2.2 (API 17) everything started working.
I just gotta say, the error that it gave me is the most convoluted error message that I've ever received in the history of my programming career.

No Resource found error When trying to Run James Montemagno Navigation Template for Android

I downloaded XamAndroidTemplateVSIX.vsix and it has been added to Visual Studio fine. The problem is when I try to build it says No Resource found that matches the given name:attr'colorPrimary'.
It's like it's not recognizing any resources from the styles.xml folder even tho the folder is in the values folder.
My SDK and Build Tools are all up to date. API 23.
What could be causing this error please?
That's because the Android support libraries are outdated. Open the NuGet package manger and update them to the latest version and your app will compile without any problems.

Categories