Couldn't Start UWP project in Xamrin Forms - xamarin

I am starting my first Xamarin Forms application using Visual Studio 2015. The default template provided 6 Project. (Android,iOS,PCL,UWP,8.1,windows phone).
All the projects works correctly including the Android,8.1,Windows Phone Emulator.
But when i try to deploy the UWP project , breaks (Exception) at the first statement where it calls the MainPage inside PCL. This happens in both Local Machine and Emulator. (debug Mode , All CPU).
I have already updated xamarin forms to the latest stable release, updated Visual Studio but i am not able to resolve the issue.
Exception:
An exception of type 'System.TypeLoadException' occurred in
Xamarin.Forms.Platform.UAP.dll but was not handled in user code
Additional information: Could not find Windows Runtime type
'Windows.UI.ViewManagement.StatusBar'.
Please Help

The Windows.UI.ViewManagement.StatusBar is a type that is only available in the Windows Mobile Extension SDK and you have to reference this SDK for it to be available.
Right-click your UWP project in the Solution Explorer, select Add -> Reference, then under Universal Windows select Extensions and find Windows Mobile Extensions for the UWP. Check the one that matches the targeted Windows 10 build version of your app.
You also need to use the IsTypePresent API, which will check at runtime if the type is available on the current device. This is important, because StatusBar does not exist on any other version of Windows 10 than on Mobile:
if(ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") )
{
//your code
}

Look like issue in xamarin UWP concept , are you updated Xamain.Forms ?
Goto Tools-> NuGet Package manager -> Manage Package for Solution -> Microsoft.NETCore.Universal Windows Platform -> update latest version.
after updated all , still same problem please check here some around
https://forums.xamarin.com/discussion/64731/how-to-solve-unknown-type-in-uwp-app-windows-ui-viewmanagement-statusbar

If none of this work try updating your windows SDK to the latest version. It worked for me. I also added the reference to Windows Mobile Extensions for the UWP.
EDIT:
I also have experimented that sometimes when you update visual studio it fails again. I had to manually change de SDK version in my UWP project, going to Properties > Application > Target Version > Select latest version

Related

Xamarin Android SDK Manager doesn't save locations

Using Visual Studio 2017 and Xamarin, I installed the Xamarin Android SDK Manager to replace the default Android SDK Manager, which is now deprecated.
Then I updated JDK to the current x64 version and, using the Xamarin SDK Manager, I installed the most recent version of Android NDK.
I now want to update the locations of these SDK's in the Xamarin Android SDK Manager, Locations tab like so:
Yet, every time I restart the tool, the locations are reset. It also keeps telling me there's 2 components to install, yet when I do, it doesn't complain about any failure.
I have tried running as Admin and cannot seem to figure out what is wrong. Log files seem to be non existent. Is there anyone who has the same problem and found a solution?
This was a bug and has been fixed in 0.1.76.
See https://bugzilla.xamarin.com/show_bug.cgi?id=58319 for details.
Download the newest version here: https://marketplace.visualstudio.com/items?itemName=Xamarin.XamarinAndroidSDKManager

Unable to see list of emulator devices for Xamarin Android in VS 2015

I am using VS 2015 enterprise update 3. After fresh installation, I created a new project--> cross platform tools--> Blank Xaml App(Xamarin.Forms Portable). then made Andriod project is default project from Solution explorer.
Tried select a device but none is available, altough when i open SDK Manager i can see 3 devices.
Andriod error
List of devices
Did you setup your android project as your startup project?
Werid because in your screenshot it shows your portable project as your startup project. This is how it looks like when i debug my android project.

Android SDK could not be found - Android SDK Location is correct

I've installed Xamarin and tried in Visual Studio to start with a small app and test the web view with this. So for this, I've installed the JDK, the Android SDK and Android NDK on my computer. I'm working throught a tutorial for a web view and I have the problem, when I run the Main.axml, it shows me the error, that my Android SDK could not be found (look at the first attachement). When I check my location paths for the JDK, SDK and NDK, it shows me the correct path and a green tick, so the path and files are correct (look at the second attachement). But my app don't recognize it. What's the problem here? I found some threads on stackoverflow for the same problem, but nothing helped me.
1. Attachement
2. Attachement
OS: Windows 8.1
IDE: MS Visual Studio 14.0.23
Xamarin: 4.2.0
EDIT:
I also tried to open my Android SDK Manager, but this one is disabled in my visual studio. I've installed Xamarin, so it should work:
Any ideas? Thanks.
I tried so many things and finally I have the solution for my problem:
Possible reason for the problem: I just installed the Xamarin, which installes also the JDK, Android SKD and Android NDK in it's wizzard, so I thought this should be the correct versions. After installing Xamarin, I opened my Visual Studio and checked the paths (Tool - Options - Xamarin - Android seetings) for my JDK, SDK and NDK. The paths show on the versions, which were installed by Xamarin. My Android SDK Manager was disabled.
Solution: Then I uninstall everything - the JDK, SDK and NDK and also the whole Xamarin and my old Android Studio. After that, I decided to install the newest JDK from the Java website, the newes Android SDK/NDK from the Android Studio website and a plane xamarin without the sdk/jdk installation. So I could be sure, that I have the correct versions. After the installation, I again opened Visual Studio - Tool - Options - Android seetings and set the paths to the new versions. Than I checked my Android SDK Manager and it was finally enabled and so I installed also the newest Android SDK Tools. After that I cleaned and builded my solution, start it and my android emulator opens my webview page. So I think, the best way is to install the required programms from their website and not automaticlly with xamarin. Now it works. Cheers.

Error in VS2015 installation and Xamarin UWP not working

I'm trying to install VS2015 Community in my PC.
When I install everything at the end the installer gives to me the following message:
I've tried to install, reinstall, update but anything changed. The only consequence that I can see is that when I create a new Xamarin solution, when I run the UWP project using Local Machine as target it starts, but then I obtain this exception message.
If I run the application from the Mobile emulator, it starts without problems.
Somewhere (sorry, I forgot the source) I've read that I should be sure to add following references for the project:
Windows Desktop Extensions for the UWP
Windows Mobile Extensions for the UWP
But I've only the first one, not the second. Maybe it's related to the installation issue?
I'm new to Xamarin and UWP, but UWP should be run to both Mobile devices and desktops, so why I have this behaviour? and what I can try to solve the installation problem that's probably related to this?
So, at the end, what I can try in order to fix the installation and allows the xamarin UWP project to run correctly in the local machine?
If I run the application from the Mobile emulator, it starts without problems.
According to your error message, it seems you are using StatusBar in your project.
While using StatusBar, please note that this is not a Universal API, this class can be only used in Mobile Device. Because status bar only exists in Mobile devices, there is no such thing in desktop, table or IoT devices. So if you use this class on Local Machine, you will get an error, but in Mobile Emulator, it can work without problems.
For more info, please see Requirements section of StatusBar.
Usually, when using StatusBar, we would use it with Runtime API check like following:
Windows.UI.ViewManagement.StatusBar statusBar = null;
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
}
if (statusBar != null)
{
//TODO
}
On Local Machine, as there is no StatusBar, ApiInformation.IsTypePresent method will return false. This will help us avoid the error. For more info, please see Write adaptive code.
But I've only the first one, not the second. Maybe it's related to the installation issue?
I'm not sure why you can't find the Windows Mobile Extensions for the UWP. But if you have used StatusBar and can build and run your project in Mobile Emulator, then you must have referenced Windows Mobile Extensions for the UWP. Without this extension, we can't use StatusBar and the build will fail.
Depending on the SDK you've installed, you can find following extensions in Reference Manager (Right click "References" in your project and then select "Add Reference" → "Universal Windows" → "Extensions").
I'd suggest you create a new Blank App (Universal Windows) project with Visual Studio to see if you have both the Desktop Extensions and Mobile Extensions. If you still have problem in new Blank App, I'd suggest you use Visual Studio Uninstaller to uninstall Visual Studio completely and also check the Control Panel to make sure you have uninstall all related stuffs like the SDKs. Then you can try to reinstall Visual Studio to see if it works.

Designer not working for Android Xamarin app

I am 100% new to Xamarin seem to have done something wrong in Visual Studio 2015. I am just trying to view my Main.axml file however the designer is giving me the following error:
A valid Android SDK could not be found. An existing SDK with platform tool and at least one platform needs to be registered with the IDE.
Do I need to do soemthing specific to fix this?
As you can see I am targeting Android 4.1 API 16.
Another weird issue is that the Android SDK Manager is disabled is this normal?
visual studio -> tools ->options:
To launch Android SDK Manager I have to launch Android studio and click on Android SDK Manager :
I had same issue with my sdk on visual studio. I could not open sdk manager from visual studio and xamarin designer could not open even though i pointed to an sdk location. however, other things worked correctly. Updating sdk from android studio and upgrading jdk to 1.8.0_102. solved my problem.
While the Xamarin is updating, that error can see.
Solved is found the tools zip file:
C:\Users\User Name\AppData\Local\Android\android-sdk\temp\tools_r25.2.4-windows (or your active last tools, doesnt matter. for ex. tools_r23.0.1)
-> Open that zip and unzip in "tools" folder.
-> Cut that folder and, paste parent folder (C:\Users\User Name\AppData\Local\Android\android-sdk)
Delete files from this path:
C:\Users\ ++ Your Windows Account Here ++ \AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache\

Resources