Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to fix a nuget package installation error

$
0
0

Hello everyone

My problem is about installing nuget Xamarin.Essentials package for Android.
To isolate the error I started a new empty Xamarin project that I called "test".
I am installing this package directly from Visual Studio and I have the error:

**All packages are compatible with MonoAndroid, Version = v8.1.
Package restore failed. Rolling back package changes for 'test.Android'.
**
I did not find a solution to my problem on the internet.
Can someone help me and tell me where this error comes from and how to solve it.

Thank you for your answers
YC


The "LinkAssemblies" task failed unexpectedly.

$
0
0

Hello,

I am hoping someone can help me here. I spent the whole morning to resolve this error and hitting the wall each time.

The min. Target framework is Android 5 level 21
Target Android version is Android 9 level 28
Version number 1.1
Version Name 1.1.0

The application works in debug mode but not in the release mode. You can see part of the error below:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5): Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Android.Support.V7.App.NotificationCompat/MediaStyle' (defined in assembly 'Plugin.MediaManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Support.V7.App.NotificationCompat/MediaStyle
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType (Mono.Cecil.TypeReference reference) [0x00013] in :0
..........

I appreciate your help and advice.

Kind regards,

Kamal

client.PostAsync("Url", null) Gets 401 unauthorized error REST API

$
0
0

I am developing a cross mobile app using Xamarin and I am trying to post some items to a SharePoint List.

I have created a windows form app just to test the SharePoint Rest API and it is working good, I have the following code:

        var username = "user";
        var password = "pass";
        var domain = "domain";

        var handler = new HttpClientHandler
        {
            Credentials = new NetworkCredential(username, password, domain)
        };

        var client = new HttpClient(handler);

        HttpResponseMessage content = client.PostAsync("/mysite/_api/contextinfo", null).Result;

the content variable (HttpResponseMessage) returns me a 200 Status code, which is OK and everything is working.

However I have the same code in my Xamrin Froms but it is not working it throws me a 401 unauthorized error

this is my Xamarin Code

    private async void BtnRestApi_OnClicked(object sender, EventArgs e)
    {
         var username = "user";
         var password = "pass";
         var domain = "domain";

         var handler = new HttpClientHandler
         {
             Credentials = new NetworkCredential(username, password, domain)
         };

          var client = new HttpClient(handler);

         HttpResponseMessage content = await client.PostAsync("/mysite/_api/contextinfo", null).Result;
    } 

Xamarin.Forms *needs* a hot reload system

$
0
0

Flutter is winning the hearts and minds of developers. I can see there is already jobs opening asking for flutter knowledge. Everywhere I read about flutter, people praise one functionality: "hot reload". I tested it and it is really nice. The thing is, flutter does not need it as much as XF. On flutter, things look the same on both devices so you do not spend so much time doing micro adjustments to the UI as on XF. The thing, I think, is that people learning need to see the changes they make to understand and learn. A person that does not know xaml will have a hard time even doing basic things look half decent. An experienced developer will have a hard time making things look exactly how he wants. It is possible but takes a lot of time.

I know about LiveXAML (http://www.livexaml.com/), I use it and it mostly works but it is not free. I know about XAMLator (https://github.com/ylatuya/XAMLator) and HotReload (https://github.com/AndreiMisiukevich/HotReload) but one only works on mac and the other I could not make work on android emulators. So, if this amazing developers are doing it, it is possible.

I think the most important thing for this feature is to be able to edit xaml on VS and see the change on emulators (android and iOS). It would be amazing if it could reload code changes too but only xaml will be a good start. It would be nice too if it could work without Visual Studio too, so I can edit .xaml files on VSCode and see the changes on my running app. This would make things so much better for experienced developers and for newcomers.

So my question is: when will Xamarin.Forms have an official hot reload system?

HotReload LiveReload LiveXaml [Mac] [Windows] [nuget package] [opensource]

ChangeCanExecute is not working, why?

$
0
0

Hello there!

I have some commands on my ViewModels, and I realized that I can them multiple times at the same time, and is getting me some troubles with updating data from a WebApi.

The basic structure I have is something like:

        private Command _LoadCommand;
        public Command LoadCommand
        {
            get { return _LoadCommand ?? (_LoadCommand = new Command(async() => await ExecuteLoad())); }
        }

        private async Task ExecuteLoad ()
        {
                IsBusy = true;
                SendSignatureToSAP.ChangeCanExecute();

                await DoSomething();

                SendSignatureToSAP.ChangeCanExecute();
                IsBusy = false;
        }

I read about ChangeCanExecute and some documentation about Commands. It doesn't reccoment to call CanExecute(false) because it doesn't trigger an event or something like that. Also, I read that since a not-so-recent version of XF, it can have the value "null" and ChangeCanExecute only puts it into null again, but I don't know if this is true or if it makes sense.

So, what should I do to know if it's doing it right or not?
It's also allowing pages to trigger OnSizeAllocated when I'm in a child page, atop of it.

Thank you!

For security reasons DTD is prohibited in this XML document.

$
0
0

HI ,

I am developing an app which has PCL,where I am calling a WCF service.
I have followed step wise step from

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/walkthrough_working_with_WCF/

private async void button_Clicked(object sender, EventArgs e)
{

                objService.InsertAsync(c.name, c.OP);

    }

but I am not able to insert ,getting following error-

For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property
on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.

Could you please help urgently.

Copy file from Resources to Library\Application Support

$
0
0

Hi there,

I have a SQLite database file that I have a default version of in my Resources directory that is set to copy to the output directory on build.

On app startup I check to see if the user already has my sqlite database file in place if not I want to copy the default file from the resource directory to the user's Library\Application Support directory which I understand is where my sandboxed application can store user data.

What I've not been able to work out programatically is where is my Resource directory path is so I can issue a copy command. I looked at NSHomeWindow() and sample code

[System.Runtime.InteropServices.DllImport("/System/Library/Frameworks/Foundation.framework/Foundation")]
    public static extern IntPtr NSHomeDirectory();

    public static string ContainerDirectory
    {
        get
        {
            return ((NSString)ObjCRuntime.Runtime.GetNSObject(NSHomeDirectory())).ToString();
        }
    }

And am assuming that I use ContainerDirectory as the string representation? However that doesn't seem to point to where my Resources folder is when the app is running.


Pulse animation for xamarin forms based on SkiaSharp

$
0
0

Pulse animation for xamarin forms based on SkiaSharp

github:
repo name: SkiaPulse-Xamarin.Forms

Android Emulator taking good amount of time to launch the application

$
0
0

Installing the Mono shared runtime (debug - 1545409236)...

is taking good amount of time to restart android emulator.
On the screen of emulator it shows "Android Restarting".

Am I missing any settings ?

Thanks,
Manjushree

How to prompt the user for new upgrades to the App?

$
0
0

Is there anything built in to Forms that will check if a new version of the App is available in the App Store and prompt the user to run an upgrade? Or any third party libraries?

How to delete files using xamarin forms

$
0
0

I tried to delete file from specific directory(Folder) but it doesn't work for me

I used this sample but doesn't work

https://forums.xamarin.com/discussion/123031/deleting-the-media-file-from-storage

this is my code

  DeletePhoto.Clicked += async (sender, args) =>
            {
                var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,

                });


                if ( file != null)
                {
                    if (File.Exists(file.Path))
                    {
                        DependencyService.Get<IFileManager>().DeleteFile(file.Path);
                    }
                    file.Dispose();

                }
            };

In android

        public class FileManager : IFileManager
            {
                public void DeleteFile(string source)
                {
                    File.Delete(source);
                }
            }

In mainfest permisson is given but something didn't happen and i find the file which i deleted

Automatic Provisioning failed: An App ID with Identifier '*' is not available.

$
0
0

I used to be able to deploy to iOS devices using Automatic Provisioning in Visual Studio for Mac.
I haven't done so in a while. The last time I tried I also updated MacOs, XCode, Visual Studio for Mac and some dependent packages.

My error might be related to this, but now I can't deploy. When I try to do "Automatic Provisioning" I'm getting the following error:
"Automatic Provisioning failed: An App ID with Identifier '*' is not available. Please enter a different string."

I removed my Apple Developer credentials and put them back in again. I accepted the new License Agreement on the Apple Developer site.
I've followed the directions here: https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/apple-account-management?tabs=macos and re-entered everything.

Under preferences I can see that I have a provisioning profile.

What do I do now?
I've also noticed that the dialog in the preferences sometimes closes automatically which might be due to an error it's getting.

Mandatory app privileges

$
0
0

Hi, I'd like to double check something, please correct me if I'm wrong:
Using a NuGet package that has code that use camera (in my case ZXing.NET.Mobile that is able to scan barcodes), my assumption is that I do have to set the CAMERA privileges even if don't use these functionalities (i.e. if in my Xamarin Forms app I do not scan barcodes but only show them on screen), because when publishing to stores (in my case Google Play and Apple Store) the code is detected and the privilege required.

So here's my question: Is it mandatory to add the CAMERA privilege because of the code in the plugin even if in my app I do not use that functionality?

Error using ExportAttribute with array parameter

$
0
0

When I'm using ExportAttribute on a managed method with array parameter like this:
[Export]
public static int A(int[] b) { ... }

I'll get:
NotSupportedException: Only primitive types and IJavaObject is supported in array type in callback method parameter or return value

But "int" is a primitive type.

I've found this link on GitHub: github.com/xamarin/xamarin-android/issues/1259
But the problem isn't solved.


Document scanner via iPhone

$
0
0

Since Mac OS Mojave, Apple has introduced the ability to scan a document in a Mac application by connecting directly to the iPhone and integrating it into the application directly.

Can anyone tell me how to implement this in Xamarin.MAC ?

Thank you

Alain

Xamain - WCF Connection Issue

$
0
0

Hi,
Please help. When i tried to connect WCF service from my Xamarain Client. Not Connect. As the same time i wrote one small VB Desktop form and connect to WCF service that one working fine. I am not sure that issue. Please help. i have enclosed my full code. please any one check and give me exact solution.

WCF – SERVICE CODE

Imports System.Data
Imports System.Configuration
Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports System.Exception
Imports MySql.Data.MySqlClient

Public Class Service1
Implements IService

'Public Sub New()
'End Sub


Public objDBQueryClass As New DBQueryClass

''' <summary>
''' Check Login
''' </summary>
''' <param name="struserid"></param>
''' <param name="strpassword"></param>
''' <returns></returns>
Public Function GetLoginInfo(ByVal struserid As String, ByVal strpassword As String) As UserData Implements IService.GetUserLogin

    Dim constr As String = "server=127.0.0.1;uid=root;pwd=1235;database=ABC;"
    Using con As New MySqlConnection(constr)
        Using cmd As New MySqlCommand("SELECT FirstName, LastName FROM userdetails WHERE UserId ='" & struserid & "' And Password = '" & strpassword & "'")
            Using sda As New MySqlDataAdapter()
                cmd.Connection = con
                sda.SelectCommand = cmd
                Using dt As New DataTable()
                    Dim customers As New UserData()
                    sda.Fill(customers.GetLoginInfo)
                    Return customers
                End Using
            End Using
        End Using
    End Using

End function


<ServiceContract()>
Public Interface IService

<OperationContract()>
Function GetUserLogin(ByVal struserid As String, ByVal strpassword As String) As UserData

<DataContract()>
Public Class UserData
Private Property CustomersTable As DataTable

Public Sub New()
    Me.CustomersTable = New DataTable("CustomersData")
End Sub

<DataMember()>
Public Property GetLoginInfo() As DataTable
    Get
        Return CustomersTable
    End Get
    Set(value As DataTable)
        CustomersTable = value
    End Set
End Property

End Class

SERVER SIDE WEB.CONFIG

<?xml version="1.0"?>




<system.web>


</system.web>
<system.serviceModel>





<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>

    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

</system.serviceModel>
<system.webServer>



</system.webServer>


XAMARAIN CLIENT SIDE CODE

using ServiceReference;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace MobileApp
{
public partial class MainPage : ContentPage
{
private ServiceClient client;
public static readonly EndpointAddress EndPoint = new EndpointAddress("http://127.0.0.1:50760/Service.svc");

    public MainPage()
    {
        InitializeComponent();
        InitilizeService1Client();
        Init();
        this.client = new ServiceClient();            
    }

    private void InitilizeService1Client()
    {
        BasicHttpBinding binding = CreateBasicHttp();
        client = new ServiceClient(binding, EndPoint);         
    }

    private static BasicHttpBinding CreateBasicHttp()
    {
        BasicHttpBinding binding = new BasicHttpBinding
        {
            Name = "basicHttpBinding",
            MaxBufferSize = 2147483647,
            MaxReceivedMessageSize = 2147483647
        };
        TimeSpan timeout = new TimeSpan(0, 0, 30);
        binding.SendTimeout = timeout;
        binding.OpenTimeout = timeout;
        binding.ReceiveTimeout = timeout;
        return binding;
    }

    void Init()
    {
        BackgroundColor = ClassFiles.Constants.BackgroundColor;
        Header.TextColor = ClassFiles.Constants.MainTextColor;
        ActivitySpinner.IsVisible = false;
        LoginIcon.HeightRequest = ClassFiles.Constants.LoginIconHeight;
        EntryUserName.Completed += (s, e) => EntryPassword.Focus();
        EntryPassword.Completed += (s, e) => SignInProcedure(s, e);
    }
    private async void SignInProcedure(object sender, EventArgs e)
    {
      ClassFiles.UserLogin user = new ClassFiles.UserLogin(EntryUserName.Text, EntryPassword.Text);

        if (user.checkInformation())
        {
            await Navigation.PushModalAsync(new MainMasterDetailPage());
        }
        else
        {
            await DisplayAlert("login", "Login Not Correct, empty username or password,", "ok");
        }
    }     
}

}

using Xamarin.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Threading.Tasks;
using System.Data;
using System.Net.Http;
using System.Net;

namespace MobileApp.ClassFiles
{ class UserLogin
{
private string entryUserName;
private string entryPassword;
public UserLogin(string entryUserName, string entryPassword)
{
this.entryUserName = entryUserName;
this.entryPassword = entryPassword;
}

    internal bool checkInformation()
    {
        if (NetworkCheck.IsInternet())
        {
            ServiceReference.IService MyClient = new ServiceReference.ServiceClient();
            ServiceReference.UserData emp = new ServiceReference.UserData();
            emp = MyClient.GetUserLoginAsync(entryUserName, entryPassword);
            DataTable dt = new DataTable();
            dt = emp.GetLoginInfo(entryUserName, entryPassword);

        IF(dt.rows.count > 0) 

{

            return true;

}
else
{
return false;
}
}
else
{
return false;
}
}
}
}

Very strange error

$
0
0

Hi all togehter,
as asked in this thread:

https://forums.xamarin.com/discussion/142159/strange-error-2#latest

I have a very strange error.
As before, running as UWP works perfectly, the problem is only in Android.

After updating all files with NuGet and Visual Studio 15.9.5 i get the following error.

try
{
await Table.PullAsync($"all{Identifier}", Table.CreateQuery()).ConfigureAwait(false);
}

        catch (MobileServicePushFailedException push_ex)
        {
            ShowPushError(this.ToString() + " -> PullLatestAsync", push_ex);
        }

        catch (Exception ex)
        {
            Debug.WriteLine("<PullLatestAsync()>Unable to pull items, that is alright as we have offline capabilities: " + ex);
            return false;
        }      
        return true;

The error raises in await Table...…..
and was catched in catch (Excepiion e)

{System.Net.Http.HttpRequestException} System.Net.Http.HttpRequestException
base {System.InvalidOperationException} System.InvalidOperationException
System.Net.WebExceptionStatus.NameResolutionFailure System.Net.WebExceptionStatus

Help is needed very urgend because i have no idea where to look and what to do...

Thanks in Advance
Peter

Page on Android API 23 Looks Different Than API 24+

$
0
0

Good afternoon,

Today I'm struggling with a boring problem. I developed the layout of the pages using the emulator with android 8 API 27.
When I tested on the emulator with android 6 API 23 the pages looked very different, you can see an example in the attached images.
Yes, i want to keep compability with Android 6, but when i created the pages on android 8 i thought the layout wouldn intefer.
I'd like to know, is there any way around this problem or is the only solution is to do two different layouts for each API? The latter does not seem sensible to me.

Thank you in advance.

Combine photo images to build a video file

$
0
0

Is anyone aware of a cross platform (iOS & Android) implementation of something that will allow me to create and export a video file based on a series of selected images/photos ? Ideally I'd also like to be able to set the delay between each frame in the video.

Many thanks for any help you can give.

Steve

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>