Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 58056 articles
Browse latest View live

The "LinkAssemblies" task failed unexpectedly... Again, again, again... HELP!!

$
0
0

Dear, after many hours trying understand/solve this issue I'm without ideias in this moment, thus, I would like get suggestions about how I can better investigate/debug this issue to try evoluting in a solution.

I did generate my last Play Store release in december 14. After that, I had working in some bugs and improvements, but I not introduce new nuget packages (I not remember). Then, today when I try generate a new release I get this infamous error:

error MSB4018: The "LinkAssemblies" task failed unexpectedly.
error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
error MSB4018: at Mono.Linker.Steps.MarkStep.SearchPropertiesForMatchingFieldDefinition(FieldDefinition field)
error MSB4018: at Mono.Linker.Steps.MarkStep.MarkFields(TypeDefinition type, Boolean includeStatic, Boolean markBackingFieldsOnlyIfPropertyMarked)
error MSB4018: at Mono.Linker.Steps.MarkStep.ApplyPreserveInfo(TypeDefinition type)
error MSB4018: at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
error MSB4018: at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
error MSB4018: at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
error MSB4018: at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
error MSB4018: at Mono.Linker.Steps.MarkStep.Initialize()
error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)
error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

My app uses Xamarin.Forms, Xamarin.Forms.Maps, Xamarin.Auth, HockeySDK.Xamarin and a lot of other packages. All my enviroment is in the last versions (Visual Studio 15.5.2, Xamarin.Forms 2.5.0.121934, Xamarin.GooglePlayServices v60.1142.0, Xamarin.Auth 1.5.0.3, Xamarin.Android.Support.* 26.1.0.1 and ...). I can not imagine a motivation in my recent changes to generate this problem. Of course, If I compile in debug mode all works fine. If I generate a new demo project and add some packages used in my app, all works fine.

But, the more curious fact: if I get my last generated release on december 14 from my git repository and try build I also get the infamous error! :s :s :'( In the meantime, the only relevant additional fact I remember is the Visual Studio upgrade to version 15.5.2. :# :#

I already tried a lot of suggestions of other related topics, but nothing works. Anybody know some productive way of I investigate/debug this issue? :/


DateTimePicker in xamarin forms

$
0
0

Is there is any DateTimePicker control is available in Xamarin forms PCL applications?

in xamarin form how to generate thumbnail from video file

$
0
0

hi,
is there any way in xamarin form how to generate thumbnail from video file?

Json to dataset

How to translate text in Xamarin forms?

$
0
0

How to translate a message into different language in xamarin forms?

I have an application which have one Editor and a "Translate" button,when user type a message in english and press "Translate" button then it will translate with specified language and show the translated language in a display alert.

So what can be possible ways to do it?

Show Google Charts on Xamarin Forms using WebView with HTML and JavaScript

$
0
0

Hi all,
I want to show a Line Chart in WebView by using HTML and Javascript code provided by Google Charts (https://developers.google.com/chart/interactive/docs/gallery/linechart#curving-the-lines). I tried with the WorkingWithWebview sample Xamarin Forms project (https://developer.xamarin.com/samples/xamarin-forms/WorkingWithWebview/) and inside class "LocalHtmlBaseUrl", I pasted the following pieces of HTML code:

htmlSource.Html = @"<html>
                        <head>
                            <script type=""text/javascript"" src=""https://www.gstatic.com/charts/loader.js""></script>
                            <script type=""text/javascript"">
                                google.charts.load('current', {'packages':['corechart']});
                                google.charts.setOnLoadCallback(drawChart);

                                function drawChart() {
                                    var data = google.visualization.arrayToDataTable([
                                    ['Year', 'Sales', 'Expenses'],
                                    ['2004',  1000,      400],
                                    ['2005',  1170,      460],
                                    ['2006',  660,       1120],
                                    ['2007',  1030,      540]
                                    ]);

                                    var options = {
                                    title: 'Company Performance',
                                    curveType: 'function',
                                    legend: { position: 'bottom' }
                                    };

                                    var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

                                    chart.draw(data, options);
                                }
                            </script>
                        </head>
                        <body>
                            <div id=""curve_chart"" style=""width: 900px; height: 500px""></div>
                        </body>
                    </html>";
//  htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get();       //Try to get loader.js locally

But when running on Genymotion device, it just shows up a Blank White Page. I also tried to load the file "loader.js" with src=""loader.js"" from Android Assets folder by download it from "https://www.gstatic.com/charts/loader.js", but no luck. I was stuck with this for nearly 2 days but still don't know what are the causes of this issue. Can someone help me to resolve this problem and show the chart correctly?

I'll really appreciate your help.
Thank you very much.

unable to connect to xamarin live player

$
0
0

Hi

Unable to connect my android phone to visual studio through xamarin player.

Connection test : Wifi : turnedon, ip : valid, Server access : Not reachable - Unable to aaccess remote server. Please ensure port 8090 is open to outbound traffic. Do i need to run any server on machine?

Mobile : wifi , Desktop : LAN but both sharing the same network in same IP series.

Please anyone help me out from this issue.

Thanks in advance

System.Data.SqlClient implementation problem

$
0
0

Hi all,

I am newbie on Xamarin. I just started developing an application for testing. It's empty now, only one button grid etc.

When I run application, It's running without error, but if I add System.Data.SqlClient from Nuget package manager and adding "using:system.data.sqlclient on my application, I cannot running application error says: "(1,1): error: Dependent project Test6.csproj failed to build, using old version."

Any idea?

Thanks..


What is the difference between Activities and Pages?

$
0
0

What is the difference between Activities and Pages in the Xamarin.Forms? I've searching for some features, but they only works in activities, but I'm working with Pages, there are any differences between then?

Unable to find a constructor to use for type Microsoft.AspNetCore.Sockets.Client.HttpConnection

$
0
0

I am trying to use Microsoft.AspNetCore.SignalR.Client in a Xamarin Forms project.
My android application work fine in Debug Version.
But it doesn't work in Release version (Android Options => Linking = "Sdk and User Assemblies" ).
Exception : Invalid negotiation response received. ---> Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type Microsoft.AspNetCore.Sockets.Client.HttpConnection+NegotiationResponse. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'connectionId', line 1, position 16.

Include a new project in my solution CrossPlatform

$
0
0

When i go to include a new project in my solution(PCL) what kind project do i add? ClassLibrary(Windows) or ClassLibrary(PCL). This new project is to create new DLL only. I use Xamarin.Forms.

Navigation property binding issues using Grouping in Xamarin MVVM

$
0
0

Please help me I am new to Xamarin form, I want to bind to the properties of ICollection (Navigation Property). I tried many approaches it did not work for example I tried I need to do that for work any help will be appreciated. I am using MVVM helper plus James Montemagno grouping and used prism also

Thanks

Public Class Category{
public int ID {get;set;}
public string CatName {get;set;}
public virtual ICollection items {get;set;}
}
Public Class Item{
public Id {get;set;}
public Catname{get;set;}
public ItemName {get;set;}
Public virtual SubItems {get;set;}
}
Public Class SubItem{
public Id {get;set;}
public ItemName{get;set;}
public SubItemName {get;set;}

}
Public Class Expandable : BaseViewMdoel{
public Catagory CataGory{ get;set;}
public bool IsSelected {get;set;}

}

Public Class ExpandableListView : BaseViewModel{
public ObservableRangeCollection CollectionOfCatagory { get; } =
new ObservableRangeCollection();
public ObservableCollection<Grouping>SelectedCatagroy
{ get; set; } = new ObservableCollection<Grouping<Expandable, Catagory>>();

public DelegateCommand<Grouping<Expandable,Catagory>> HeaderCommand
{get
{
return new DelegateCommand<Grouping>(g =>
{
if (g == null) return;
g.Key.IsSelected = !g.Key.IsSelected;

            if (g.Key.IsSelected )
            {
                foreach (var item in CollectionOfCatagory )
                {
                     var m = item.Catagory.Where(i => i.ID == 
                     g.Key.Catagory.ID);
                    foreach (var x in m)
                    {
                        g.Add(item);                                                  
                    } 
                }

                }
            else
            {
                g.Clear();
            }
        });
    }
}

Void GroupListOfItem(){
var items = CollectionOfCatagory.Select(
x => new Expandable{ Catagory = x, IsSelected = false }
).GroupBy(c => new { c.Catagory.CatName}).Select(g =>
g.First()).ToList();
items.ForEach(c => SelectedCatagroy.Add(new
Grouping<Expandable, Catagory>(c, new
ObservableRangeCollection())));
}
}

<ListView.GroupHeaderTemplate>
    <DataTemplate>
        <ViewCell>
            <ContentView Padding="10,0,0,0">
                <Label Text="{Binding Key.Catagory.CatName}" 
            VerticalOptions="Center"/>
            <ContentView.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding Source=
             {x:Reference CatagoryListPage}, 
             Path=BindingContext.HeaderCommand}"  CommandParameter="
             {Binding .}" />
            </ContentView.GestureRecognizers>    
            </ContentView>
        </ViewCell>
    </DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
    <DataTemplate>
        <ViewCell>
            <StackLayout  Padding="10,0,0,0">
                <StackLayout Orientation="Horizontal">
                    <StackLayout  WidthRequest="40">
                        <Label Text="{Binding Catname}" />
                    </StackLayout>
             <Label  Text = {Binding How To bind to properties of 
                             navigation Please help} 
                    </StackLayout>
                    <Image Source="Cat1"/>
                </StackLayout>
            </StackLayout>
        </ViewCell>

Key exchange protocol implementations in Xamarin.Forms PCL

$
0
0

Are there any secure key exchange protocol implementations available for PCL projects, such as DH?

Badge icon on the Button

$
0
0

I'm developing a new app and in this app i have 7 buttons. I need to send message or notification(but not PN) to these App represented by these buttons. Is possible to create a REST to send message or notification(not PN) for each button, but each button to receive a badge? Anybody knows some tutorial or link that can explaim me?

JsonDataSource can not read JSON File

$
0
0

Hi,

I have a website under Drupal 8.
I created a json file at the root of my website for the test the method.

</p:ListDataPage.DataSource> But I can not read the JSON file. I do not have an error while compiling.
My app is based on this method xamarin.com/guides/xamarin-forms/user-interface/datapages/getting-started/

If I move the same json file to another site I can read it. Do you have an idea? I am stuck for several days.

Thanks in advance.


What's the best way to change font sizes/colors on tabs?

$
0
0

In using the TabbedPage, I'm noticing that the font size and color is awfully hard to read on a tab in iOS. I presume this is default for iOS, but it's a terrible default.

What do I need to do to change the font size and color (iOS only) for a tab?

notice in the screenshot that the words "Additional Media" are difficult to read, and the font size in general is quite small.

Tabbed Page - Tab Sizes

$
0
0

I'm having a problem in resizing the tabs in a tabbed page. In portrait view(on a phone emulator) the tabs automatically extend to the end of the view, in landscape(or in a tablet emulator) the tabs have a fixed size, is there a way to extend them to the end?

How do I hide TableView header/footer with a custom renderer on iOS?

$
0
0

I am wanting to create a page layout where I display multiple TableViews along with other views such as a Label in between each.

In doing this I need the ability to:

  1. Make the TableView not default to a vertically expanded layout option (the default which does not seem changeable) so that they can be stacked in a StackLayout vertically.
  2. Hide the corresponding UITableView section header/footers so that there isn't excess vertical spacing between.

I have achieved this with the following CustomTableView control:

public class CustomTableView : TableView
{
    public bool NoHeader { get; set; }
    public bool NoFooter { get; set; }

    protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
    {
        if(!VerticalOptions.Expands)
        {
            // Call OnSizeRequest that is overwritten in custom renderer
            var baseOnSizeRequest = GetVisualElementOnSizeRequest();
            return baseOnSizeRequest(widthConstraint, heightConstraint);
        }

        return base.OnSizeRequest(widthConstraint, heightConstraint);
    }

    public Func<double, double, SizeRequest> GetVisualElementOnSizeRequest()
    {
        var handle = typeof(VisualElement).GetMethod(
            "OnSizeRequest",
            BindingFlags.Instance | BindingFlags.NonPublic,
            null,
            new Type[] { typeof(double), typeof(double) },
            null)?.MethodHandle;

        var pointer = handle.Value.GetFunctionPointer();
        return (Func<double, double, SizeRequest>)Activator.CreateInstance(
            typeof(Func<double, double, SizeRequest>), this, pointer);
    }
}

and the custom iOS renderer for this which follows the advise from this SO answer for hiding UITableView headers/footers:

public class CustomTableViewRenderer : TableViewRenderer
{
    public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
    {
        Control.LayoutIfNeeded();
        var size = new Size(Control.ContentSize.Width, Control.ContentSize.Height);
        return new SizeRequest(size);
    }

    protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
    {
        base.OnElementChanged(e);

        if(e.NewElement is CustomTableView view)
        {
            Control.ScrollEnabled = false;
            SetSource();
        }
    }

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);
        var view = (CustomTableView)Element;
        if(e.PropertyName == TableView.HasUnevenRowsProperty.PropertyName)
        {
            SetSource();
        }
    }

    private void SetSource()
    {
        var view = (CustomTableView)Element;
        if(view.NoFooter || view.NoHeader)
        {
            Control.Source = new CustomTableViewModelRenderer(view);
        }
        else
        {
            Control.Source = Element.HasUnevenRows ? new UnEvenTableViewModelRenderer(Element) :
                new TableViewModelRenderer(Element);
        }
    }

    public class CustomTableViewModelRenderer : UnEvenTableViewModelRenderer
    {
        private readonly CustomTableView _view;

        public CustomTableViewModelRenderer(CustomTableView model)
            : base(model)
        {
            _view = model;
        }

        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            if(_view.HasUnevenRows)
            {
                return UITableView.AutomaticDimension;
            }

            return base.GetHeightForRow(tableView, indexPath);
        }

        public override nfloat GetHeightForHeader(UITableView tableView, nint section)
        {
            if(_view.NoHeader)
            {
                return 0.00001f;
            }

            return base.GetHeightForHeader(tableView, section);
        }

        public override UIView GetViewForHeader(UITableView tableView, nint section)
        {
            if(_view.NoHeader)
            {
                return new UIView(new CGRect(0, 0, 0, 0));
            }

            return base.GetViewForHeader(tableView, section);
        }

        public override nfloat GetHeightForFooter(UITableView tableView, nint section)
        {
            if(_view.NoFooter)
            {
                return 0.00001f;
            }

            return 10f;
        }

        public override UIView GetViewForFooter(UITableView tableView, nint section)
        {
            if(_view.NoFooter)
            {
                return new UIView(new CGRect(0, 0, 0, 0));
            }

            return base.GetViewForFooter(tableView, section);
        }
    }
}

I then create a simple Xamarin.Forms ContentPage to implement this as such:

public class TablePage : ContentPage
{
    public TablePage()
    {
        Table1 = new PageTableView
        {
            BackgroundColor = Color.Cyan,
            Root = new TableRoot
            {
                new TableSection("Table 1")
                {
                    new LabelEntryTableCell("Label A"),
                    new LabelEntryTableCell("Label B")
                }
            }
        };

        var label1 = new Label
        {
            Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                "Vivamus accumsan lacus orci. Nulla in enim erat.",
            Margin = new Thickness(15, 5, 15, 0),
            BackgroundColor = Color.Yellow
        };

        Table2 = new PageTableView
        {
            BackgroundColor = Color.Red,
            Root = new TableRoot
            {
                new TableSection("Table 2")
                {
                    new LabelEntryTableCell("Label C"),
                    new LabelEntryTableCell("Label D")
                }
            }
        };

        var label2 = new Label
        {
            Text = "Duis vulputate mattis elit. " +
                "Donec vulputate lorem vitae elit posuere, quis consequat ligula imperdiet.",
            Margin = new Thickness(15, 5, 15, 0),
            BackgroundColor = Color.Green
        };

        StackLayout = new StackLayout
        {
            Children = { Table1, label1, Table2, label2 },
            Spacing = 0
        };

        BackgroundColor = Color.Gray;
        Title = "Custom Table View";
        Content = new ScrollView
        {
            Content = StackLayout
        };
    }

    public PageTableView Table1 { get; set; }
    public PageTableView Table2 { get; set; }
    public StackLayout StackLayout { get; set; }
}

public class PageTableView : CustomTableView
{
    public PageTableView()
    {
        Intent = TableIntent.Settings;
        HasUnevenRows = true;
        RowHeight = -1;
        VerticalOptions = LayoutOptions.Start;
        NoFooter = true;
    }
}

public class LabelEntryTableCell : ViewCell
{
    public LabelEntryTableCell(string labelText)
    {
        var label = new Label { Text = labelText };
        var entry = new Entry();

        View = new StackLayout
        {
            Children = { label, entry },
            BackgroundColor = Color.White,
            Padding = 10
        };
    }
}

This all seems to work as expected, however, when the TablePage first displays much of the CustomTableView content is chopped off. I can then rotate the device to landscape and the problem corrects itself, showing my layout as I intend. Then rotating then device back to portrait still shows the correct layout with no more information from the CustomTableView being chopped off anymore in that orientation either. This happens consistently every time. See a demo of this here:

Rotating fixes the problem

I can also fix the problem by adding this to the TablePage:

protected override void OnAppearing()
{
    base.OnAppearing();

    // This will also fix the problem, but you see a flash of the old layout
    // when the page first displays.

    var l = new Label();
    StackLayout.Children.Add(l);
    StackLayout.Children.Remove(l);
}

How do I correct this problem? My custom control/renderer/page works as intended whenever I do the rotation/OnAppearing hack to correct it and I am not sure why. It seems like I need to call some re-draw method on the UITableView.

Sample Project

If you want to see the full source/project for this isolated test scenario you can find it on GitHub here.

Problem on updating Xamarin.Forms

$
0
0

Hi,
I am using Xamarin Forms with visual studio 2017 .. the new project is always has Xamarin.Forms v 2.3.3.191.
The project doesn't work .. it stops on (InitializeComponent) on the MainPage .. just stops and nothing happening.
I thought the problem is with Xamarin.Forms version, so I installed the update of Xamarin.Forms .. the version 2.5.0.121934 (Last Stable)
Then when I rebulid the Android project it gives me that error

Severity Code Description Project File Line Suppression State
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.Fragment.dll'

Install .apk and keep data from old app. How?

$
0
0

I have app running with many peoples. Then i need to install a new version, but if i install the newer version i have this message:

INSTALL_FAILED_UPDATE_INCOMPATIBLE

If i uninstall the old version i loss all data. I need to update, but i'm not getting. The message say: Incompatible, but why? What can be incompatible? What am i doing wrong?

Viewing all 58056 articles
Browse latest View live