Can not resolve reference: `Windows.Foundation.UniversalApiContract in Android App - xamarin

I developed a Xamarin Cross Platform application that is working perfectly on Windows but when I try to recompile for Android I get the following error:
Can not resolve reference: `Windows.Foundation.UniversalApiContract
I use the Windows.Foundation.UniversalApiContract reference because of the Windows.Storage class (generate files in internal memory).
I understand that I may have to change the recording method on Android but I can't even get to that stage...
How do I resolve this situation?

Just as ToolmakerSteve said, Windows namespace relies on features that exist only in Windows. The reference should not be in the main .Net Standard library but in the UWP Application.
First, you can move the code to the Windows folder or set the #if Windows around it.
Second, you can write the code for each platform. I found the answer you can refer to Can not resolve reference: Windows.Foundation.UniversalApiContract in Android Application.

Related

error CS0234: The type or namespace name 'Persistence' does not exist in the namespace 'UnityEngine.XR.WSA' (are you missing an assembly reference?)

I'm currently developing an app for android. In my code, I use the namespace UnityEngine.XR.WSA.Persistence. When I'm launching the app on the editor, i have no errors, but when I try to build this to send it to my phone, I get the following one :
The type or namespace name "Persistence" does not exist in the
namespace "UnityEngine.XR.WSA". Are you missing an assembly
reference?"
Isn't it strange since it's working on the editor? How do i fix it?
WSA stands for Windows Store Apps. This is only available when building apps for Universal Windows Platform. Especially UnityEngine.XR.WSA.Persistence afaik is or at least was previously developed by Microsoft and is even only used in particular for the HoloLens.
It throws no exceptions in the Editor but afaik some #if preprocessors make sure that it also does nothing there.
It is not available when building an App for Android platforms.
To remove the error in your script you can use #if preprocessors and Platform dependent compilation like
#if UNITY_WSA
// anything using the UnityEngine.XR.WSA namespace
#else
// alternative implementation for different platform
#endif
however, the functionality ofcourse will not be available on Android so if you need something similar you have to use another library or come up with one ;)

Xamarin Shared Library namespace cannot be found

My shared library cannot resolve using RestSharp; among other related namespaces. RestSharp is an installed package and is resolvable in the Droid/iOS projects but cannot be found in the Shared Library. I know this works because I'm using RestSharp in a MonoGame project in the same way. The shared library is referenced in the Droid/iOS projects but still fails during compilation.
Any advice? I tried clean all.
Update I created a new Cross Platform Native app solution and I was able to reference in my shared library without issue. That original project is a bit older and was created with PCL originally. I still want to know why it's not working in my original solution.
I continued to have lots of namespace and type not found issues. Once I showed warnings instead of just errors I found that the csproj was missing. After removing the reference in the native apps and re-adding the issue was resolved. Quite frusterating.

Xamarin iOS - Parse.com issue registering subclasses?

I am working with Parse.com whilst building an app with Xamarin for iOS. I have built an Android version with no issues, everything working. However, when I try to register a Custom Parse Object before initializing Parse.com client I have an issue where I can't actually register objects.
As you can see my Parse iOS project is trying to reference the Parse Android library. I have no idea why?
Has anybody else seen this or know if I am registering these classes incorrectly?
Okay so managed to figure this one out.
As I have a shared code library for both Android and iOS that references the Parse library, I needed to make sure that the shared code library references the Parse version of the platform I was working on.
For example, whilst building my Android application the shared code library that referenced Parse objects needed to reference the Parse.Android library.
When moving to iOS part of the project I made sure my shared code library referenced the Parse.iOS library.
Hope this makes sense to anyone out there.

Reference dll in xamarin

I am using Xamarin and I am new to it. I need to reference a dll which already uses System.Drawing due to which I am getting error. I know we can't use it because it is built aroung GDI+.
So plz let me know what should I do to successfully refer my dll. Even if I remove reference of System.Drawing from my dll then it is getting errors as it is using Bitmap, Image,Size etc. If I have to remove System.Drawing dll then how should I resolve the errors. Is there something else that can be used instead of Bitmap,Image,Size etc.
Plz help me and guide me with simple explanation as I am a beginner
As you found out there is no System.Drawing in Xamarin on mobile. Thus you might reuse sources (I assume you have those) into android(?) library and instead of Drawing types use Android (or iOS) ones. That would require code changes though.
Xamarin Droid already has such classes in framework. You don't need to reference external dll's. All you need to do to start using them is using Android.Graphics; in your class.

OpenCV_HelloWorld project in VC++ 2010 Runtime Error:

I set up the environment according to this tutorial:
http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010
However the picture they want you to use is no longer there, so I just saved the supplied screen shot with the same name as the original file.
Builds fine, Begins to run but then I get a runtime error
Here is the runtime error:
OpenCV_HelloWorld.exe - Application Error : The application was unable to start correctly (0xc0150002). Click OK to close the application.
I looked in Event Viewer and found that it also set off a another error but did not announce
Here is the unannounced error:
Activation context generation failed for "C:\OpenCV2.1\bin\cxcore210d.dll". Dependent Assembly Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.
As you can see it says to use sxstrace.exe however I don't appear to have that program. After a quick Google I read that the program was included in the Microsoft Windows Platform SDK, so I'm downloading the most relevant version (windows 7 version for c# and .net) and installing that to follow up on that, I'll post what I find as it comes.
Any help is very much appreciated
Unexpectedly the project builds and runs now. The only modifications made were removing spaces in the c++ directory and linker options from the tutorial. External changes were the completed installation of the windows platform SDK, however OpenCV has no dependencies with windows platform sdk. I am unsure how it was resolved, but it's no longer a problem.

Resources