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

Error build on Iphone after update

$
0
0

Yesterday i update my iphone to version 13.4.1

Sinds then i have an error building to my Iphone in visualstudio for Mac ( image Catalina)

I know the free space is below the 3 gigabyte because then there is a warning , but is it the update or the free space that is to little ?

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(3,3): Error MSB4018: The "EmbedMobileProvision" task failed unexpectedly.
System.Exception: Did not find XML plist in buffer.
  at Xamarin.MacDev.PDictionary.FromBinaryXml (System.Byte[] array) [0x0002c] in <d570b8d8ffe74cd4b8f1635c165d955d>:0 
  at Xamarin.MacDev.MobileProvision.LoadFromFile (System.String fileName) [0x0000e] in <d570b8d8ffe74cd4b8f1635c165d955d>:0 
  at Xamarin.iOS.Tasks.EmbedMobileProvisionTaskBase.Execute () [0x000eb] in <d570b8d8ffe74cd4b8f1635c165d955d>:0 
  at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:574 
  at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002a9] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:814  (MSB4018) (OFB.iOS)




Can any one please can help me with my problem with BindingContext?

$
0
0

Hi, everyone I need help for my problem. I am trying to bind the context from the viewmodel like this

<ContentPage.BindingContext> <viewModels:BLEConncetViewModel/> </ContentPage.BindingContext>

and also I have a constructor inside my view model that it have some parameters on it, here its starts the problem because when I try to bind it appears this message Type 'Type BLEConnectViewModel' is not usable as an object element because is not public or does not define a public parameterless constructor or a type converter. No default constructor found.

And the constructor is like this: I am using Prism container.

public BLEConncetViewModel(INavigationService navigationService, IAdapter btAdapter)
{
_navigationService = navigationService;
_btAdapter = btAdapter;
_btAdapter.DeviceDiscovered += OnDeviceDiscovered;
OnClickCommand = new DelegateCommand(OnClick);

    }

Thanks.

Collapsing Toolbar Layout in Xamarin Forms

Draw Arabic Text using Skiasharp

$
0
0

Hi,

I'm trying to render Arabic text using Skiasharp, with no success. The characters are rendered disconnected and from left to right, please see the image below.

Any help would be appreciated, preferably without any special font or custom renderer...etc.

Thanks,

The simulator stucked since the searchBar is focused?

$
0
0

In IOS simulator after I clicked the SearchBar the APP stucked,why?

I can not click anywhere

it works well in the physical phone

Setting an external Font-Family for android.support.v7.widget.Toolbar

$
0
0

Hi Everyone,

I am trying to change the Font-Family of the Toolbar. I have tried the following without any luck, could someone please point me in the right direction.

  1. Assets folder - Imported my TTF (.Droid and .NET Standard project), marking the build actions as an Embedded Resource
  2. android.support.v7.widget.Toolbar.xml - Added an entry for app:titleTextAppearance="@style/ActionBarTitleStyle"
  3. styles.xml - Created a style name="ActionBarTitleStyle" with android:fontFamily set to "Montserrat-Medium"
  4. I have also tried adding android:fontFamily="Montserrat-Medium" directly into the android.support.v7.widget.Toolbar.xml
  5. Application.Resources - Tried to set the FontFamily as a Property targeting NavigationPage (Toolbar unavailable)

The Toolbar.xml came as default on the project in the .DroidProject/resources/layout folder along with Tabbar.xml

Attempt #1 - Set android:fontFamily via app:titleTextAppearance

<android.support.v7.widget.Toolbar 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:background="?attr/colorPrimary"
  android:layout_height="wrap_content"
  android:layout_width="match_parent"
  app:titleTextAppearance="@style/ActionBarTitleStyle"/>
<style name="ActionBarTitleStyle" parent="android:Widget.TextView">
    <!-- The action bar title font -->
    <item name="android:fontFamily">Montserrat-Medium</item>
    <!-- Customizes the color of the action bar title-->
    <item name="android:textColor">#ffffff</item>
    <!-- Customizes the size of the action bar title-->
    <item name="android:textSize">19sp</item>
  </style>

Attempt #2 - Directly adding an entry for android:fontFamily="Montserrat-Medium"

<android.support.v7.widget.Toolbar 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:background="?attr/colorPrimary"
  android:layout_height="wrap_content"
  android:layout_width="match_parent"
  android:fontFamily="Montserrat-Medium" 
  app:titleTextAppearance="@style/ActionBarTitleStyle"/>

Attempt #3 (Build Failed)- Trying to target the Property FontFamily on a TargetType as NavigationPage with the Value set to Montserrat-Medium

//AssemblyInfo.cs
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: ExportFont("Montserrat-Medium.ttf", Alias = "Montserrat-Medium")]
    <Application.Resources>
        <x:StyleSheetExtension Source="GlobalStyles.css" />
        <Style TargetType="Button">
            <Setter Property="CornerRadius" Value="18" />
            <Setter Property="FontFamily" Value="Montserrat-Medium" /> <!-- THIS WORKS for a Button-->
        </Style>
        <Style TargetType="NavigationPage">
            <Setter Property="FontFamily" Value="Montserrat-Medium" />
        </Style>
    </Application.Resources>

My App randomly crashing and seems to be doing so because of SkiaSharp

$
0
0

Hi. My app is crashing.... so I put some debug statements (AI - .....) in the code to see why and it seems to be related to SkiaSharp:

05-24 10:06:11.408 I/mono-stdout(30859): AI - Keep Max - End
05-24 10:06:11.408 I/mono-stdout(30859): AI - Keep Max
05-24 10:06:11.408 I/mono-stdout(30859): AI - Keep Max - End
05-24 10:06:11.408 I/mono-stdout(30859): AI -Play Scandal On Player
05-24 10:06:11.436 V/MediaPlayer(30859): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
05-24 10:06:11.436 V/MediaPlayer(30859): cleanDrmObj: mDrmObj=null mDrmSessionId=null
05-24 10:06:11.615 D/Mono    (30859): Requesting loading reference 3 (of 10) of /storage/emulated/0/Android/data/com.companyname.potocracy/files/.__override__/Potocracy.dll
05-24 10:06:11.615 D/Mono    (30859): Loading reference 3 of /storage/emulated/0/Android/data/com.companyname.potocracy/files/.__override__/Potocracy.dll asmctx DEFAULT, looking for SkiaSharp, Version=1.68.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
05-24 10:06:11.615 D/Mono    (30859): Assembly Ref addref Potocracy[0xe31ffb20] -> SkiaSharp[0xe31ffd00]: 2
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'

05-24 10:06:22.803 E/mono    (30859): Full thread dump:

"Debugger agent"
"Thread Pool Worker"

"Thread Pool Worker"
"Finalizer"
"<unnamed thread>"  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception) <0x00012>
  at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/mcs/class/corlib/System.Diagnostics/Debugger.cs:120
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.42 (intptr,intptr) [0x00020] in <4ccdb3137d974856b786e1aeebbfbab6>:0
  at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.42 (intptr,intptr) [0x00030] in <4ccdb3137d974856b786e1aeebbfbab6>:0

"Timer-Scheduler"

"<threadpool thread>"
"Thread Pool Worker"
05-24 10:06:32.851 I/libc    (30859): Requested dump for tid 30859 (yname.potocracy)

However, my App only uses SkiaSharp on one page. That page has always worked when I called it... and in my testing I am not calling it.

The code running at the time of the crash is not even remotely related to SkiaSharp. I use SkiaSharp to create a gameboard map and it is only called when the user clicks a button. I'm not clicking that button.

Any ideas? I commented out all the code on the SkiaPage that I am not calling... and my app doesn't seem to be crashing anymore. How do I use SkiaSharp without the problem? What is Xamarin doing behind the scenes with the page (without my consent)?

Thank you.

Android binding issue

$
0
0

Hallo,

maybe somebody can help help. Android is just not updating the control or not binding in the first place. Using UWP & IOS everthing works fine. I was using different Kind of conecpts, Always IOS & UWP is working as expected, Android dont't. I use the Emulator or a device attached

I tried even with a very simple Code, no error, Android is just not showing the Elements in the picker control

<Picker ItemsSource="{Binding GetTracks}" ItemDisplayBinding="{Binding TrackName}"/>

` public class GetTracks
{
private int trackID;
public int TrackID
{
get { return trackID; }
set { trackID = value; }
}
private string trackName;
public string TrackName
{
get { return trackName; }
set { trackName = value; }
}
}

public class AnalyseViewModels
{

    private ObservableCollection<GetTracks> getTracks;
    public ObservableCollection<GetTracks> GetTracks
    {
        get { return getTracks; }
        set { getTracks = value; }
    }

    public AnalyseViewModels()
    {
        getTracks = new ObservableCollection<GetTracks>();

        getTracks.Add(new GetTracks() { TrackID = 1, TrackName = "TEST1" });
        getTracks.Add(new GetTracks() { TrackID = 2, TrackName = "TEST2" });
        getTracks.Add(new GetTracks() { TrackID = 3, TrackName = "TEST3" });
        getTracks.Add(new GetTracks() { TrackID = 4, TrackName = "TEST4" });
        getTracks.Add(new GetTracks() { TrackID = 5, TrackName = "TEST5" });

    }`

Thanks for an advice :)

Markus


share Authentication access token

$
0
0

Hi
I Have xamarin forms application, authenticate with asp.net membership and give accesstoken after authenticate.
In other platforms (ex silverlight, javascrip libs ....), this token access shared accross all requests to server (ex webclient,httpclient, image source request and ...) and all requests send it to server automaticaly
how can I share this token on xamarin forms for all requests?
I cant set cookies for all requests handly. because some of them like imagesource does not have any way to set it

Xamarin Forms Language issues on Android

$
0
0

I'm going crazy for hours on an evil problem!!!

I've created a new Xamain Forms prj on Visual Studio for Mac (last version and last update).

I have three AppResources files for corrispondent languages: - AppResources.resx (for default) - AppResources.it.resx (for italian) - AppResources.es.resx (for spanish)

On IOS simulator, works all good. On Android I see always the default string.

This is my simple data on AppResources file:

AppResources.resx:

Default

AppResources.es.resx:

Espanol

AppResources.it.resx:

Italiano

Why on IOS works perfectly and on Android I can see only "default"?!?

(UWP) How to clear GUI objects and get memory back???

$
0
0

https://www.github.com/ssombat/xamarinUWPMemory
I created a small sample project. I post the 2 main files to GitHub.
The project just added 200 "OuterFames" (A frame within a frame that has a button) in a flex layout.
And we clear the flexlayout's children. This runs in a loop with some sleeps in-between.
Basically adding and removing those gui objects to the screen.
In theory, memory shouldn't keep growing but it does.


After 5 mins of running, the memory usage is over double than it should be.
I also tested by implementing IDisposable but no changes.
Is there something I'm doing wrong?
Memory leak in the framework?

Background image is stretched, is there any way to make it fit according to screen sizes?

$
0
0

hi is there any way to set the background image to fit the screen size in content pages(xamarin.forms),i think the default settings is set to stretched.

How to use SVG images for Xamarin.Forms?

$
0
0

It seems it's possible to some extent to use SVG images in some controls, for instance SVG files can be only added as embedded resources when using some of the available NuGet packages out there. Also, at least for ToolbarItem the images need to be stored somewhere in the file system, so I had to create my own SVG rasterizer that saves those images to bitmaps in the cache directory, so those could passed in a FileImageSource to the Icon property in the control ToolbarItem. For, the control Button those images need to be stored in the Resources or drawable directory, so it won't work with the rasterized bitmaps, since those are stored in the cache directory. With all those limitations for trying to use SVG files directly at runtime, I was thinking maybe I could convert all those images to the corresponding JPG or PNG images at build time using some task, but I'm not sure whether that conversion could be done with the current available tools. So, my questions is how to use directly or convert SVG images to use in the common controls in Xamarin.Forms (ToolbarItem, Button, etc)?

Unable to use Toast, Activity Indicatior

$
0
0

I have a simple Xamarin Form app with a .net standard project and Android Project. I am facing a problem since day of development is that , I am unable to pull Toast and Activity Indicator on form. I dont know why. I tried almost all major plugins as well.

Here's my login code where I want to see a toast. I have used UserDialogs, Forms.Plugin etc and now using Plugin.Toast.

  protected void BtnLogin_Clicked(object sender, EventArgs e)

        {
            try
            {
                CrossToastPopUp.Current.ShowToastMessage("Message"); // Plugin.Toast package
                var userName = TxtUserName.Text.Trim();
                var password = TxtPassword.Text.Trim();
                userController.DoLogin(userName, password);
            }
            catch (NullReferenceException)
            {
                DisplayAlert("Mobile # and Password, both are required.", "JCAA", "OK");

            }
            catch (Exception ex)
            {
                DisplayAlert(ex.Message, "JCAA", "OK");
                Crashes.TrackError(ex);
            }


        }

DataTemplateSelector running out of resources

$
0
0

I have a very simple list of 8 objects. They are in an ObservablesList. When I use a datatemplate as a local resource, when the app is loading in Android the "OnTemplateSelected" function is called 4 times for each item in the list... when I reach the 23 resource limit the app crashes.... What this means is that Datatemplates are a non-starter for Android projects.

So, the question is... how do I deal with this issue? I am all for using whatever technique that makes sense... But I have 8 different objects that I believe require no less than 5 different displays depending on the information changes... I have to display between 3 and 12 icons for each object. These are not "static" in nature, so each item could be different with any given application launch. My displays would need to be in multi-lines for mobile... possibly 7 per line... like;

Any suggestions on how to accomplish this would be fantastic!!!

{Image - Name }
{Information label}
X X X

{Image - Name }
{Information label}
X X X X

{Image - Name } {display of more than 7 icons for ease of use}
{Information label}
X X X X X X X
X X X X X


Android Custom Renderer is not changing height after PropertyChangedEvent

$
0
0

Hi,

there are 2 views on a page. The views are inside a StackLayout. The views are Grids. One Row of the Grid is MyView which is renderer by a custom renderer.
By clicking onone view the properties of the MyView is swapped. MyView one is displaying the content of MyView two and the other way around.
However, after changing the property the height of MyView is not adjusted correctly to it's content depending on their property. My View is keeping the height of MyView from it's previous content.

I think the problem is inside the custom renderer which is not changing the height of MyView correctly after a PropertyChangedEvent.

[assembly: ExportRenderer(typeof(MyView), typeof(MyViewDroidRenderer))]
namespace pnyxnetmobile.Droid.Renderer
{
    public class DroidRenderer : ViewRenderer
    {
        private MyLinearLayoutBuilderAndroid _builder;

        public DroidRenderer(Context context) : base(context)
        {
            //Init Builder
            _builder = new MyLinearLayoutBuilderAndroid(context);
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                MyView view = e.NewElement as MyView;
                //Generate a LinearLayout
                SetNativeControl(_builder.GenerateLinearaLayout(view));
            }
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            MyView view = sender as MyView;
            //Value is the property which is changed
            if (MyView.ValueProperty.PropertyName.Equals(e.PropertyName))
            {
                if (view != null){
                    SetNativeControl(_builder.GenerateLinearaLayout(view));
                    Control.RequestLayout();
                }
            }
        }
    }
}

Data after the Camera Capture always return Null

$
0
0

Good Day All

i am opening an Intent for Camera and I take a photo and when i save i want to get the saved file . i open my intent like this

                           Intent takePicture = new Intent(MediaStore.ActionImageCapture);
                           var  mPhotoUri = this.Activity.ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, new ContentValues()); 
                            takePicture.PutExtra(MediaStore.ExtraOutput, mPhotoUri); 
                            StartActivityForResult(takePicture, 0); 

and in the Activity results i do this

       public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            if (requestCode == 0)
            {
                Uri u = null;
                if (hasImageCaptureBug())
                {
                    Java.IO.File fi = new Java.IO.File("/sdcard/tmp");  
                   u = Uri.Parse(Android.Provider.MediaStore.Images.Media.InsertImage(this.Activity.ContentResolver, fi.AbsolutePath, null, null)); 
                }
                else
                {
               **     u = data.Data; **
                }
      }

The intent gives me null

     u = data.Data;  

Thanks

Is there any Xamarin.Forms Camera2 sample that actually works, including all the features I need?

$
0
0

Hi,

for the past 12 months I've been looking into upgrading my Xamarin.Forms app that uses the deprecated Camera API in the android renderer to the new Camera2 API. I've tried many samples, but none of them were exactly what I needed. Some didn't work at all, some did, but were missing key features.

What do I need?
Pretty much a clone of the native camera app minus the camera settings. I need a camera view that is showing the photo preview, can take photos (take photo button) and has some additional information overlayed on top of the camera preview (just some TextViews).

The best of the samples I've found (the UNIT-23 sample) still wasn't as reliable as I'd like. It worked, however, sometimes it would just crash for no apparent reason and the stack trace wasn't very useful. The other ones either had fewer features implemented or were only Xamarin.Android examples.

The samples I've tried were (I can't post links, so here are the repository names):

  • The official Xamarin Camera2 Basic sample
  • The official Xamarin Camera2 Raw sample
  • UNIT-23/Xam-Android-Camera2-Sample
  • vtserej/Camera2Forms
  • HofmaDresu/AndroidCamera2Sample
  • thekeviv/CameraFeed

I've also searched this forum, Xamarin.Forms docs, StackOverflow, and Google with no 100% working results.

Is there an example that could help me achieve the thing I want?
Thank you

Scrollview works with slight problem

$
0
0

I have a pop-up working just fine but the problem occurs when the keyboard is present on the screen. Attached are my screenshots of what is happening and I am unsure of how to solve it. The popup window goes behind MGMT Notes/Detail Notes/Postmortem. I am unsure of how it to remain on top of the layer.

Would you need to see the code of the Main Detail page or the popup?

MessagingCenter.Unsubscribe occasionally fails to unsubscribe

$
0
0

Is there a situation where calling Unsubscribe can fail?

I have an application which listens for connection then allows the remote to register as a remote monitor. Any status updates will then be sent to this monitor using the MessagingCenter.

The monitor "RemoteMonitor" creates a subscription to a message within it's constructor and removes this subscription when the underlying connection is disconnected. For test purposes the remote is creating many connections (50 ish) then being disconnected and a status update is being sent to detect the disconnections.

`internal RemoteMonitor(string id, HttpConnection sourceConnection) : base("remotemonitor", MappedObjectType.NotSerialisable)
    {
        Log.GetInstance().WriteInfo(GetType(), "{" + UId.ToString() +"} Adding remote monitor to parent conId{" + m_sourceConnection.UId + "}"); 
        m_sourceConnection.ConnectionClosed += M_sourceConnection_ConnectionClosed;
        MessagingCenter.Subscribe<StatusMap>(this, MessageStrings.MedaiPlayerStatusChanged, (sender) => SendStatus(sender));
    }

private void M_sourceConnection_ConnectionClosed()
    {
        Log.GetInstance().WriteInfo(GetType(), "{" + UId.ToString() + "} Removing remote monitor from parent conId{" + m_sourceConnection.UId + "}");
        MessagingCenter.Unsubscribe<StatusMap>(this, MessageStrings.MedaiPlayerStatusChanged);
    }`

Looking at the log we can see that connection closed has been called for this instance
RemoteMediaPlayer.Models.Map.RemoteMonitor(13500): {37} Removing remote monitor from parent conId{36}

And only one instance of the Subscription was ever created
RemoteMediaPlayer.Models.Map.RemoteMonitor(13500): {37} Adding remote monitor to parent conId{36}

Yet SendStatus continues to be called

Android version 4.4.2
Xamarin Forms 4.6.0.726

Viewing all 89864 articles
Browse latest View live


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