Everything seemed to work fine, however when I try to load an image from remote url, it shows up blank on debug device. This is when deploying from VS on Windows to physical iPhone device.
It works fine in iOS simulator and Android emulator.
Tried the following:
image.Source = new Uri(url);
image.Source = ImageSource.FromUri(new Uri(url));
As well as things like loading the image from stream using ImageSource.FromStream
My best guess is it has got something to do with permissions?! But the app seemingly connects just fine with the server API. Why would it have any trouble loading image from the same server?
Update:
It seems the problem only exists when debugging from Windows (Using Xamarin Hot Restart). Deploying the same project from a Mac didn't cause the same error. Hoping for a fix to this specific issue, as developing on Windows is my personal preference.
Related
I am having an issue with the UDPClient in Android 10 (worked fine in Android 9) so Im assuming Im missing from Android 10 that I have yet to be able to find so far.
I have a UDPService (background service) running which is a pretty standard implementation (Port is 64200)
m_udpSocket = new UdpClient(m_port);
m_udpSocket.Client.ReceiveTimeout = (int)m_healthTimeout.TotalMilliseconds;
m_healthSocket.Client.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, (int)m_healthTimeout.TotalMilliseconds );
I wont post the sending and receiving code at this stage as I think its more permissions related.
The client periodically sends some UDP data to the server for processing. Its all local network based (not internet) and the data is sent via the WiFi on the device.
In Android 9, it all works as expected with the app in the foreground or the background.
In Android 10, it works perfectly when the app is in the foreground, but when the app goes to the background, when I try to issue the send on the socket
System.Net.Sockets.SocketException (0x80004005): Access denied
This error only happens in release mode on Android 10. If Im running in Debug Mode attached to the device, I can put the app into the background and the UDP traffic works as expected.
Based on all the above, Im assuming there is something else I need to do to allow the socket to work in the background in release mode but I cant seem to put my finger on what it is. Ive read about INTERNET permission and how Debug mode automatically adds this so is there something else I may be missing in the Android Manifest that could cause this.
Any help would be greatly appreciated.
Thanks in advance.
For anyone experiencing similar problems, in the end it had nothing to do with the actual code, but it was the Battery Optimisation Settings in Android.
Once I removed the app from the automatic battery optimisations, everything worked as expected.
I've been following the examples for using SkiaSharp with Xamarin Forms, particularly the section on using bitmaps. I'm doing this in Microsoft Visual Studio 2017 version 15.9.11. I'm only targeting Android currently.
This page https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/basics/bitmaps has a section on Loading a Bitmap Resource, where the bitmap is an embedded image resource in the project.
So, we add the image and make it type 'embedded resource'
and then run the example code to simply display the image on the canvas.
string resourceID = "SkiaTest.Media.monkey.png";
Assembly assembly = GetType().GetTypeInfo().Assembly;
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
{
resourceBitmap = SKBitmap.Decode(stream);
}
All pretty simple, and it works fine if I run the code on my phone if it is connected via USB in the standard way (a Sony Z5) so the second in the list here, not the Player:
Here it is working via USB:
But if I try and use Xamarin Live Player (the first in the list above) then it crashes on this line:
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
Note that the app runs fine in Live Player if I don't try and load the bitmap, it's only that line that triggers the crash, and only in Live Player.
So I wonder if anyone has any ideas what could be causing Live Player to fail over this issue? Is the resource not being copied to the phone? Does Live Player just not support this type of activity?
The reason you are facing this issue is that Embedded Resources are not yet supported by Xamarin Live player which is causing this exception.
More details can be found in the Troubleshooting Xamarin Live Player document.
I have Xamarin Live Player up and running.
When I use it with a newly created Xamarin Forms (Master Details) app, it works fine. I see the app on the device.
However, when I try to run my full-blown app, Visual Studio tells me "Deployment to device failed. Make sure that Xamarin Live Player is open and that the device is in the same network."
Since the new app runs fine, I guess something else is the problem.
I've already set the Android project properties to be same as the newly created app.
Just to make sure, I've made it so that my full-blown app requests all rights.
How could I debug more in detail what's going wrong?
Xamarin Live Player can't run all apps. As soon as you use reflection, embedded resources, a MVVM framework or a custom renderer in Xamarin.Forms it might simply just not run the App.
You can read about the limitations of Xamarin Live Player in the official documentation for it.
You will probably have a much better experience just running directly on the device without Live Player.
I have a phonegap application that has some layout problems. I can run the app in browser for the most part, and this usually get me over the line. But with a new design I need to debug the application layout on windows phone 8.
I'm currently looking at weinre but its not showing anything on the desktop when browsing the local server, I have added the link to my application I have cleaned up everything I can think of. Still blank. Any good tuts around the ones I have read just copy and paste the original docs or are not on my same error.
There's a public weinre server available here:
https://the-weinre.herokuapp.com/
You may have better luck with that than with your local server. There's a demo available on that page, give that a try and see if it works on your windows 8 mobile device.
I am working on Photo application.
In which a user can upload, view, and download pictures to and from the cloud.
For back-end I am using buddy API.
The problem I am facing is that once I choose a photo and try to upload it to the cloud it gives me 'Null reference exception' and this only happens when ran from Visual Studio (either to the device or emulator).
But once its deployed on my phone it uploads and behaves normally.
I don't know where to exactly put the blame and from where to start looking into this problem.
It fails on:
var photo = await album.AddPictureAsync(e.ChosenPhoto);
with the error:
A first chance exception of type 'System.NullReferenceException'
occurred in PhotoApplication.DLL