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

Android: Getting XA3001: Could not AOT the assembly

$
0
0

Getting error on almost all assemblies (list bellow) no matter linker option. I don't figure out where is the problem with the AOT compiler. Do you have an idea?

Assemblies impacted:

2>Projet "Chronique.Android.csproj" (Install cibles) :
2>XA3001: Could not AOT the assembly: FFImageLoading.dll
2>XA3001: Could not AOT the assembly: Chronique.dll
2>XA3001: Could not AOT the assembly: FFImageLoading.Forms.dll
2>XA3001: Could not AOT the assembly: FFImageLoading.Transformations.dll
2>XA3001: Could not AOT the assembly: Chronique.Android.dll
2>XA3001: Could not AOT the assembly: FFImageLoading.Platform.dll
2>XA3001: Could not AOT the assembly: FFImageLoading.Forms.Platform.dll
2>XA3001: Could not AOT the assembly: FormsViewGroup.dll
2>XA3001: Could not AOT the assembly: IF.Lastfm.Core.dll
2>XA3001: Could not AOT the assembly: Hqub.MusicBrainz.API.dll

Configuration:

Microsoft Visual Studio Enterprise 2017
Version 15.8.5
VisualStudio.15.Release/15.8.5+28010.2036
Microsoft .NET Framework
Version 4.7.03056

Version installée : Enterprise

Mono Debugging for Visual Studio 4.11.11-pre (8fb558f)
Support for debugging Mono processes with Visual Studio.

Xamarin 4.11.0.776 (d15-8@1ae9b59d7)
Extension Visual Studio permettant de développer pour Xamarin.iOS et Xamarin.Android.

Xamarin Designer 4.15.9 (d000f568b)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 1.1.116 (9619170)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 9.0.0.19 (HEAD/a8a3b0ec7)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 12.0.0.15 (84552a4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.


FontAwesome Label: Here's how!

$
0
0

Here's how you'll use the new FontAwesome label (Any Graphic font will work, but FontAwesome is Awesome):

var coolLabel = new FontAwesomeIcon(FontAwesomeIcon.Icon.Gear)

Here's how to set it up.

Download the FontAwesome font and unzip it. Rename the ttf to FontAwesome.ttf. Note the Case of the name. Copy it to Android /Assets and mark as a BundleAsset. Copy to iOS /Resources and mark as BundleResource and "Copy Always". In iOS edit the info.plist and add this:

  <key>UIAppFonts</key>
  <string>FontAwesome.ttf</string>

Now that we have the font in our projects we need to tell Android, and ONLY Android how to get to the Font. Here's a renderer you can just drop in FontAwesomeIconRenderer.cs:

[assembly: ExportRenderer(typeof(FontAwesomeIcon), typeof(FontAwesomeIconRenderer))]

namespace AAA.Android.Renderers
{
    /// <summary>
    /// Add the FontAwesome.ttf to the Assets folder and mark as "Android Asset"
    /// </summary>
   public  class FontAwesomeIconRenderer: LabelRenderer
    {
       protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
       {
           base.OnElementChanged(e);
           if (e.OldElement == null)
           {
               //The ttf in /Assets is CaseSensitive, so name it FontAwesome.ttf
               Control.Typeface = Typeface.CreateFromAsset(Forms.Context.Assets, FontAwesomeIcon.Typeface + ".ttf");
           }
       }
    }
}

Here's the Label for your common UI project:

namespace AAA.Common.Views.Shared.FontAwesome
{
    public class FontAwesomeIcon : Label
    {
        //Must match the exact "Name" of the font which you can get by double clicking the TTF in Windows
        public const string Typeface = "FontAwesome";  

        public FontAwesomeIcon(string fontAwesomeIcon=null)
        {
            FontFamily = Typeface;    //iOS is happy with this, Android needs a renderer to add ".ttf"
            Text = fontAwesomeIcon;
        }

        /// <summary>
        /// Get more icons from http://fortawesome.github.io/Font-Awesome/cheatsheet/
        /// Tip: Just copy and past the icon picture here to get the icon
        /// </summary>
        public static class Icon
        {
            public static readonly string Gear = "";
            public static readonly string Globe = "";
        }
    }
}

How to Implement webView Rendering and pass data in UWP ?

$
0
0

Can any one suggest me how to implement webview Rendering in UWP xamarin.forms .
Thanks in Advance.

Xamarin Forms - FontAwesome works iOS,Android but UWP display [x]

$
0
0

Hello dear Xamariners !

I'm wasting a lot of time trying to figure out why FontAwesome doesn't work on Android & iOS.
No need to tell you that I've tried several solutions I found on this forum.

To help you to help me (what ? haha)
Here are some screenshots :

On iOS :

On UWP or Android (kind of same result I don't have the right icon)

The FontFamily resource in app.xaml :

My Fonts folder :

My VS fonts Android folder with the properties AndroidAsset // copy if newer

My VS fonts UWP folder with the properties Content // Do not copy

Do you have any idea why it isn't working ?

I've tried several way to declare my font (without the otf.#name of font , with .otf#name of font style , with .otf only)

If anybody got this working, it would be awesome :) to get some help.
PS : I'd like to avoid a custom renderer

I wish you all a good weekend !

X.F Android application "SensorPortrait" orientation not working

$
0
0

Enough said...

[Activity(Label = "App1", MainLauncher = true, Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.SensorPortrait)]

gets ignored...

Xamarin Form 4.0, Shell hamburger Icon

$
0
0

Hello,

How can I add "hamburger.png" icon for iOS and UWP app with the shell flyout ?

Thanks.

Error CS0656 Missing compiler required member "microsoft.csharp.runtimerbinder.binder.convert"

$
0
0

Error CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert' App1 C:\Users\user\OneDrive\desktop\folder\App1\App1\App1\Services\ApiServices.cs line 66 Active

The error is apparently due to this line of code -->JObject jwtDynamic = JsonConvert.DeserializeObject(content);
I have tried adding a refrence to Microsoft.CSharp in the android project (which is the project i use on my emulator). And I have tried to install the Microsoft.CSharp nuget package. Nothing seems to work, so any tips are appreciated.

Where does the NuGet plugin Media save the photo file on each platform?

$
0
0

In this code, I am not sure where the File is being saved.

I get this error anyways as well:

Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project.01-18 16:35:19.171 I/mono-stdout(22873): Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project.

private async void ButtonTakePhoto_Clicked(object sender, EventArgs e)
        {
            var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
            var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

            if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted)
            {
                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera, Permission.Storage });
                cameraStatus = results[Permission.Camera];
                storageStatus = results[Permission.Storage];
            }

            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                UserDialogs.Instance.Alert("No Camera.", "No camera available.", "Ok.");
                return;
            }
            else
            {
                if (cameraStatus == PermissionStatus.Granted && storageStatus == PermissionStatus.Granted)
                {
                    try
                    {
                        var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                        {
                            PhotoSize = PhotoSize.Custom,
                            CustomPhotoSize = 90,
                            CompressionQuality = 92,

                           // Directory = "Sample",
                            Name = "test.jpg"
                        });
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                }
                else
                {
                    UserDialogs.Instance.Alert("Permission(s) denied.", "Unable to take photo.", "Ok.");
                    //On iOS you may want to send your user to the settings screen.
                    //CrossPermissions.Current.OpenAppSettings();
                }
            }

        }

Exception: "LoadTemplate should not be null" (Xamarin 1.4.0.6341)

$
0
0

Hello,
I have updated to Xamarin 1.4.0.6341 today, it all works fine but when I open
a ScrollView with a ListView inside the App crashes and the Error "System.InvalidOperationException: LoadTemplate should not be null"
appears.
When I remove the ListView from the ScrollView, the Page and the Controls onto are shown and the App don't crashes.

Thanks in advance

Indefinitely running background service X.F Android

$
0
0

Hey guys! I would like to create an Android background service that will start when my application starts and stays running indefinitely! I have tried serveral ways to achieve this with no luck whatsoever. Yes, i'm using the latest of every possible thing and yes i know it can be achieved only as platform specific, that is fine with me!

Why? It doesn't really matter, but because i want to connect to a netcore signalr server and recieve messages even when the app is not running, and yes i know that i need a broadcast reciever to start it again after the phone restarts i got everything working, except the service stops when the app gets closed.

Thank you!

UWP - "Unable to activate windows store app" from virtual drive

$
0
0

Are any of you using a virtual drive (Z:) to store your projects in? Well, I use VeraCrypt for virtual drive storage and recently started targeting UWP just to find out the hard way IT DOESN'T WORK (for me)!

When running the UWP app from VS2017 on Win10 it throws the error, Unable to activate windows store app. I've searched for countless hours beating my head & caused a project delay just to find out you must run UWP from C: to work. Wish it would just say, "hey you can't do this" rather than, reporting KernelBase.dll crapped its pants.

Seriously, have any of you encountered this and/or have a fix for this?

I tried the following without success:

  • Cleaning build/obj files (pfft)
  • Setting the Windows install apps to (Z:)
  • Reregistered UWP .pfx file
  • Manually uninstalled my UWP app

LocalNotification Based on User Location

$
0
0

Hello,
Someone know how we can Triggers Localnotification based on user lastknowlocation and some statics locations "LAng,LAnt" (like geofoncing)?
Thank you for your help.
Best regards,

Calling static methods from native app project

$
0
0

Hello i'm new to Xamarin and i wanna know.. does calling a static method on a shared code class from Andorid or IOS project considered good approach?

Thanks

CrossGeolocator.Current.GetPositionAsync() not working

$
0
0

Hello,

I'm using plugin.geolocator for getting latitude and longitude of the device. It's working fine on some Android device but it is not working for some device.

Working Device = Samsung,
Not Working Device = Motorola(MotoG)

Below is my code.

var locator = CrossGeolocator.Current; locator.DesiredAccuracy = 10; var _position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10));

ScrollToAsync ( ScrolleToPosition) not working on Android

$
0
0

Hi, My IOs project its works okey, but in android don't get the same position on the screen.

public async Task AguacateSearch()
        {
            await Task.Delay(1000);
            await ScrollCorazon.ScrollToAsync(Buscar_Aguacate, ScrollToPosition.Start, true)       
        }

Xamarin Form ContentView not work on IOS

$
0
0

I want to use contentview on xamarin form and i set inside the content view stacklayout the code below

    <ContentView>
        <StackLayout>
            <Label Text="Label"/>
            <Button Text="click me"/>
        </StackLayout>
    </ContentView>

the elements inside contentview showed on andorid but on ios did not show any element inside contentview
any one can give me any idea why not work on ios .

thanks

Bind SelectedItem in ListView to element in another page

$
0
0

I am new to Xaml, and have been scouring the web for examples, but so far all I have found is binding viewmodels commands to elements on the same page. But what I would like to do is bind elements on one page to trigger an event on another page. What I have is a Main Page:

<TabbedPage.Children>
    <pages:MapPage"  >
        <pages:MapPage.BindingContext>
            <viewModels:MapViewModel/>
        </pages:MapPage.BindingContext>
    </pages:MapPage>

    <pages:LayersPage">
        <pages:LayersPage.BindingContext>
            <viewModels:LayersViewModel/>
        </pages:LayersPage.BindingContext>-->
    </pages:LayersPage>

</TabbedPage.Children>

The Map Page holds a custom SkiaSharp control that loads maps. The LayersPage holds a listview with possible layers to load:

<ContentPage.Content>
    <StackLayout>
        <ListView x:Name="listView" 
                  ItemsSource="{Binding Layers}" 
                  Header="{Binding Intro}"
                  Footer="{Binding Summary}"
                  ItemTapped="OnItemTapped">
            <ListView.HeaderTemplate >
                <DataTemplate>
                    <StackLayout Orientation="Horizontal" 
        Padding="10,5,5,10"
        BackgroundColor="Yellow">
                        <Label Text="~~"/>
                        <Label Text="{Binding .}"/>
                        <Label Text="~~"/>
                    </StackLayout>
                </DataTemplate>
            </ListView.HeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <TextCell Text="{Binding Name}" Detail="{Binding Description}"></TextCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage.Content>

So when a layer is selected on the listview, it should raise a command/event to the MapPage, and subsequently the Map element to load layer (string) selected. I am trying to use MVVM, and I can get the list view to raise an even on the "ItemTapped" event in the LayersPage, but I am now unsure how to send that string to the MapViewModel, or even the element that has a method called AddLayer(string layer).

So I have read lots of article about commands and binding, and I feel slightly confident on binding to elements within the page, but not to other pages. Any help or step in the right direction would be appreciated.

How to avoid title view from getting shifted from the center when back button is shown on android

$
0
0

Currently, I am building an app that should run both on iOS and android. I have an image as the title view on the navigation bar which has been set to entered. When we run the app, the title view gets shifted when the back button is shown on android. But on iOS, the title view remains centered even if back button is shown. Is there anyway to keep the title view fixed at the center of the navigation bar both for iOS and android even when back button is shown.

Why do UI elements look different on different platforms?

$
0
0
The description says that Xamarin forms allows you to create an application that looks the same everywhere. But why does a simple text input box look different on Android and ios? I did not even look further. I choose between Xamarin and React Native. I know .net and therefore I wanted to use xamarin, but this is a misunderstanding with the UI. Is it possible to simply make a text field or a button that is the same everywhere without a superfluous code?

I do not want to spend my time setting up UI elements for each platform.

Deleting the Media file

$
0
0

I'm using the xam.plugin.Media library and I've been using the multimedia plug-in to capture the photo from an Android device using XF. I have noticed that the files are stored in the specified directory. My question is: how can I delete these files from storage after use? Why do they keep appearing when you put it in an img tag?

before it worked for me but under the update of xamarin form I stop working I would appreciate your help

Viewing all 89864 articles
Browse latest View live


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