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

VST build agent for Android fails to build after Forms 2.5.0.91635 upgrade

$
0
0

Hi,

We have a build issue that happens on our VST build agent only. After upgrading to Xamarin.Forms 2.5.0.91635 version, the local builds are fine. The problem is resources attributes compilation

Error CS0117: 'Resource.Attribute' does not contain a definition for 'MediaRouteControllerWindowBackground'
Error CS0117: 'Resource.Attribute' does not contain a definition for 'mediaRouteBluetoothIconDrawable'

These are just a few of many errors that point out to the attribute definitions missing.

The build engine version:

017-11-28T23:16:38.6544392Z Task : Xamarin.Android
2017-11-28T23:16:38.6544392Z Description : Build an Android app with Xamarin
2017-11-28T23:16:38.6544392Z Version : 1.119.0
2017-11-28T23:16:38.6544392Z Author : Microsoft Corporation

[
2017-11-28T23:16:41.1486756Z ##[debug] {
2017-11-28T23:16:41.1506288Z ##[debug] "instanceId": "a8029945",
2017-11-28T23:16:41.1525820Z ##[debug] "installDate": "2017-09-14T02:54:40Z",
2017-11-28T23:16:41.1545352Z ##[debug] "installationName": "VisualStudio/15.4.5+27004.2010",
2017-11-28T23:16:41.1574650Z ##[debug] "installationPath": "D:\Program Files (x86)\Microsoft Visual Studio 2017\Enterprise",
2017-11-28T23:16:41.1603948Z ##[debug] "installationVersion": "15.4.27004.2010",
2017-11-28T23:16:41.1633246Z ##[debug] "displayName": "Visual Studio Enterprise 2017",
2017-11-28T23:16:41.1652778Z ##[debug] "description": "Microsoft DevOps solution for productivity and coordination across teams of any size",
2017-11-28T23:16:41.1867630Z ##[debug]]

My problem seems to be that build task does not find the correct android level:

_BuildSdkCache:
2017-11-28T23:16:42.4348578Z sdk Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory not found.
2017-11-28T23:16:42.4368110Z sdk Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found:
2017-11-28T23:16:42.4368110Z Path does not contain ndk-stack in . (C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r11c).
2017-11-28T23:16:42.4397408Z sdk Looking for Android SDK..
2017-11-28T23:16:42.4397408Z sdk Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory not found.
2017-11-28T23:16:42.4407174Z sdk Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found:
2017-11-28T23:16:42.4407174Z Path does not contain adb in \platform-tools (C:\android-sdk-windows).
2017-11-28T23:16:42.4407174Z sdk Key HKCU\SOFTWARE\Xamarin\MonoAndroid\PrivateAndroidSdkPath not found.
2017-11-28T23:16:42.4407174Z sdk Key HKCU\SOFTWARE\Android SDK Tools\Path not found.
2017-11-28T23:16:42.4407174Z sdk Key HKLM\SOFTWARE\Android SDK Tools\Path found:
2017-11-28T23:16:42.4416940Z Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk).
2017-11-28T23:16:42.4436472Z sdk Looking for Android NDK..
2017-11-28T23:16:42.4436472Z sdk Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found:
2017-11-28T23:16:42.4436472Z Path does not contain ndk-stack in . (C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r11c).
2017-11-28T23:16:42.4446238Z sdk Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
2017-11-28T23:16:42.4573196Z Found Android SDK. API levels: 19, 21, 22, 23
2017-11-28T23:16:42.4875942Z _SetLatestTargetFrameworkVersion:
2017-11-28T23:16:42.4885708Z sdk Looking for Android NDK..
2017-11-28T23:16:42.4885708Z sdk Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found:
2017-11-28T23:16:42.4885708Z Path does not contain ndk-stack in . (C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r11c).
2017-11-28T23:16:42.4885708Z sdk Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
2017-11-28T23:16:42.4895474Z Found Android SDK. API levels: 19, 21, 22, 23

I am targeting Level 26, and I have it installed on VST agent, my resources are compiled with:
C:\Program Files (x86)\Android\android-sdk\build-tools\26.0.3\aapt.exe package -f -m -M D:\B\V11_temp\usura1uo.q3a\manifest\AndroidManifest.xml ...

So, I think the reason is that somehow the build is still using outdated sdk for the build but aapt is using the newer resource compiler?

How do I get the VST agent to refresh/update to the latest version? Could this be as simple as machine reboot :smile:

Thanks.


Adding a picker in XAML

$
0
0

I'd like to add a picker control that has the values 1,2,3,4,5.

I tried the following...

        <Picker SelectedIndex="{Binding NewCriterion.Importance}" >
            <Items>
                <x:String>"1"</x:String>
                <x:String>"2"</x:String>
            </Items>
        </Picker>

to no avail. The documentation is a bit sparse on how to do this in XAML. Help?

How to deploy a Xamarin.Forms iOS application to iPhone/iPad ?

$
0
0

Hello ,

I have an Xamarin.Forms application and for now I tested my application on iPhone Simulator (I am using Parallels Desktop on MAC using Visual Studio 2015)

Now I need to send my application to device.

Is there any way to do that from Windows 10 / Visual Studio 2015 BTW (Parallels Desktop)

If I cant do that from Visual Studio how can i deploy my application ?

Links & Useful answers would help.

Thank you for your help !

Request permissions not working within PermissionsPlugin

$
0
0

For my Xamarin.Forms-App I'm using the PermissionsPlugin v2.0.1.

If no permission is granted, I want to request the user to do so by CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage)

The problem is that the function always returns Unknown instead of requesting the user for the permission. One time, it worked...but I don't know what I changed that it's not working anymore..

Here my code:

MainActivity.cs (Android-project)

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
    base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

AndroidManifest.xml

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="25" />
<uses-permission android:name="android.permission.CAMERA" />

PermissionsExample.xaml.cs

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PermissionExample
{
    public PermissionExample()
    {
        this.InitializeComponent();
    }

    private async void Button_OnClicked(object sender, EventArgs e)
    {
        var requestedPermissions = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Camera);
        var requestedPermissionStatus = requestedPermissions[Permission.Camera];

        await this.DisplayAlert("", $"Permission: {requestedPermissionStatus}", "ok");
    }
}

Thanks for your help! :)

Context is obsolete as of version 2.5

$
0
0

I updated my project to Xamarin forms 2.5. When I use Xamarin.Forms I get warning:

  Context is obsolete as of version 2.5. Please use a local context instead

How use local context instead?

Assertion failure -[UITableView -endCellAnimationsWithContext:]

$
0
0

I have been upgrading an old Xamarin project by porting the code to the latest version. In the Android project it works fine but in the iOS project when I navigate to a specific page I get:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.6.22/UITableView.m:1610
The app has been terminated.

In the code I do following:

` var labSystemEventsListView = new ListView
{
ItemsSource = _viewModel.Events,
BackgroundColor = Color.Transparent,
HasUnevenRows = true,
ItemTemplate = new DataTemplate(typeof(EventListViewCell))
};

        // Hide the list view until we have results to display
        labSystemEventsListView.SetBinding(IsVisibleProperty, "Loading", BindingMode.Default, new BooleanNegationConverter(), null);

        labSystemEventsListView.ItemSelected += async (sender, args) =>
        {
            var selectedEvent = args.SelectedItem as EventModel;
            if (selectedEvent == null)
                return;

            if (selectedEvent.Confirmed)
            {
                ((ListView)sender).SelectedItem = null; // de-select the row
                return;
            }

            var answer = await DisplayAlert("Confirm event", "Would you like to confirm this event?", "Yes", "No");
            if (answer)
            {
                selectedEvent.ConfirmEvent();
            }

            ((ListView)sender).SelectedItem = null; // de-select the row
        };

        Content = new StackLayout { Children = { filterLayout, ActivityIndicatorFactory.GetBoundActivityIndicator(), labSystemEventsListView } };
    }

    /// <summary>
    /// Fires when the page appears on screen,
    /// reloads data from the API so we always display fresh information
    /// </summary>
    protected override void OnAppearing()
    {
        base.OnAppearing();
        _viewModel.GetEventsAsync(false);
    }`

Which calls GetEventsAsync the data is requested successfully but not displayed....

` public async void GetEventsAsync(bool filter)
{
try
{
Loading = true;

            Events.Clear();

            Events = new ObservableCollection<EventModel>();

            EnsureCancellationToken();

            await EnsureAuthenticationToken();

            List<EventModel> events;

            var eventsOperation = new EventsOperation(null, ((App)App.Current).ApiAuthenticationToken);
            events = await eventsOperation.GetEventsAsync(LabSystem.IDMComponentId, _cts.Token);

            foreach (var evt in events)
                Events.Add(evt);
        }
        catch (Exception ex)
        {
            ex.WriteToLog("Error");
        }
        finally
        {
            Loading = false;
        }
    }`

Why is this happening?

Cross Platform Crop Image View

$
0
0

Hey,

Anyone have ever implemented some custom crop image UI that can be used in forms ios/android/win phone?
What I`m trying to achieve is something like instagram that crop a image to a square, so I can store in a db and show it in a circle image after to give my app a better design.
Someone have anything like this? So I will not start from scratch...

Thanks

Xamarin Forms photo Pan/Scale/Crop plugin?

$
0
0

Hi,
I'm making app with using XF pcl.

To make photo viewer/editor function, you should add Pan/Scale/Crop.
Is there good plugin that somebody already have done for it?

Of course I can make my own but
It's very common behavior so I'm curious.

Thanks.


Subscription-based app?

$
0
0

Hello,

I have a requirement for a subscription-based app...

The user purchases use of the app for a year.
The user gets reminded to renew and/or auto-renew a certain period before end of subscription.
After end of subscription period, app restricts access and directs user to renew subscription.

Can someone please point me at the correct way(s) to implement something like this? (per platform - iOS and Android).

Thx

Guidance Requested on Xamarin.Auth or Alternatives

$
0
0

I have an internal Xamarin.Forms PCL application that is targeted to iOS, Android and UWP platforms. I need to provide social sign-in to Facebook and Google. I have been recommended to use Xamarin.Auth; downloaded the ironically named Comicbook sample and I spent a several hours looking through it with no success. Can anyone guide me to a relatively understandable documentation/walkthru/guide that exists for Xamarin.Auth 1.5.0.3 ? Alternatively, can anyone point me to a "licensable" alternative that I will be more than glad to pay for given the state/disarray of documentation and guidance on Xamarin.Forms ?

Xamarin.Forms 3.0 release date

$
0
0

Is there any more recent information that can be shared as to the release date of Xamarin.Forms 3.0?

We are looking to start building a number of Xamarin apps and want to use the Embedding Feature as described in (https://blog.xamarin.com/glimpse-future-xamarin-forms-3-0/.

We would prefer to be able to start off with Native projects and embed Xamarin.Forms content especially to get early iterations of screens done which may later become fully native.

The roadmap states that this will be Q4 2017.

Many thanks,
Richard

API Service - How to show Debug.Writeline in DisplayAlert or Label?

$
0
0

Hello together,

I'm trying to make a Registration Page for an App by using the API Service of Visual Studio. I have successfully wrote the Code to registrate new User and to deserialize and to Debug.WriteLine the json Answer of the API Service. Now I'm not able to show this answer (like The user is registered successfully or wrong password...) in a Display Alert or a Label in the Xaml. Is this even possible? I don't know how to transport the information.

Thank you for your help :smiley:

My code:

API SERVICE:

public class ApiServices
{
public void Register(string email, string username, string password, string confirmPassword)
{
var client = new HttpClient();

        var model = new RegisterBindingModel
        {
            Email = email,
            UserName = username,
            Password = password,
            ConfirmPassword = confirmPassword
        };

        var json = JsonConvert.SerializeObject(model);

        HttpContent content = new StringContent(json);

        content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

        var response = client.PostAsync("httpxxxxx", content).Result;

        try
        {
            if (response.IsSuccessStatusCode)
            {
                Debug.WriteLine(
                "Der neue User {0} wurde erfolgreich hinzugefügt.", email);
            }
            else
            {
                var ex = CreateApiException(response);
                throw ex;
                // Debug.WriteLine(response);
                // Debug.WriteLine(await response.Content.ReadAsStringAsync());
                // Debug.WriteLine(response.StatusCode);
            }

        }
        catch (AggregateException ex)
        {
            Debug.WriteLine("One or more exceptions has occurred:");
            foreach (var exception in ex.InnerExceptions)
            {
                Debug.WriteLine("  " + exception.Message);
            }
        }
        catch (ApiException apiEx)
        {
            var sb = new StringBuilder();
            sb.AppendLine("  Ein Fehler ist aufgetreten:");
            sb.AppendLine(string.Format("    Status Code: {0}", apiEx.StatusCode.ToString()));
            sb.AppendLine("    Fehlermeldung:");
            foreach (var error in apiEx.Errors)
            {
                sb.AppendLine("      " + error);
            }
            // Write the error info to the console:
            Debug.WriteLine(sb.ToString());

        }

    }

    public static ApiException CreateApiException(HttpResponseMessage response)
    {
        var httpErrorObject = response.Content.ReadAsStringAsync().Result;

        // Create an anonymous object to use as the template for deserialization:
        var anonymousErrorObject =
            new { message = "", ModelState = new Dictionary<string, string[]>() };

        // Deserialize:
        var deserializedErrorObject =
            JsonConvert.DeserializeAnonymousType(httpErrorObject, anonymousErrorObject);

        // Now wrap into an exception which best fullfills the needs of your application:
        var ex = new ApiException(response);

        // Sometimes, there may be Model Errors:
        if (deserializedErrorObject.ModelState != null)
        {
            var errors =
                deserializedErrorObject.ModelState
                                        .Select(kvp => string.Join(". ", kvp.Value));
            for (int i = 0; i < errors.Count(); i++)
            {
                // Wrap the errors up into the base Exception.Data Dictionary:
                ex.Data.Add(i, errors.ElementAt(i));
            }
        }
        // Othertimes, there may not be Model Errors:
        else
        {
            var error =
                JsonConvert.DeserializeObject<Dictionary<string, string>>(httpErrorObject);
            foreach (var kvp in error)
            {
                // Wrap the errors up into the base Exception.Data Dictionary:
                ex.Data.Add(kvp.Key, kvp.Value);
            }
        }
        return ex;
    }

MY RegisterModel.cs

{
public class Registrierungsansicht
{

    ApiServices _apiServices = new ApiServices();

    public string Email { get; set; }

    public string UserName { get; set; }

    public string Password { get; set; }

    public string ConfirmPassword { get; set; }

    public class ApiException : Exception
    {
        public HttpResponseMessage Response { get; set; }
        public ApiException(HttpResponseMessage response)
        {
            this.Response = response;
        }


        public HttpStatusCode StatusCode
        {
            get
            {
                return this.Response.StatusCode;
            }
        }


        public IEnumerable<string> Errors
        {
            get
            {
                return this.Data.Values.Cast<string>().ToList();
            }
        }
    }
    public string ex { get; set; }

    public ICommand RegisterCommand
    {
        get
        {
            return new Command(() =>
            {

                 _apiServices.Register(Email, UserName, Password, ConfirmPassword);


                   });
        }
    }
}

MY RegisterPage xml:

<ContentPage.BindingContext>

    <viewModels:Registrierungsansicht/>

</ContentPage.BindingContext>




<StackLayout Orientation="Vertical" >
    <Entry Text="{Binding Email}"
           Placeholder="Email"/>
    <Entry Text="{Binding UserName}"
           Placeholder="Benutzername"/>
    <Entry Text="{Binding Password}"
           Placeholder="Kennwort"
           IsPassword="True"/>
    <Entry Text="{Binding ConfirmPassword}"
           Placeholder="Kennwort bestätigen"
           IsPassword="True"/>

    <Button Command="{Binding RegisterCommand}"
            Text="Register"/>

    <Label Text="{Binding Errors}"/>

    <Button Text="Log In"
            Clicked="Button_OnClicked"/>

</StackLayout>

Android App Running With Latest Xamarin.Forms NuGet

$
0
0

I CANNOT get an Android app to compile with the latest Xamarin Froms NuGet package. I've tried everything.

Does someone anywhere have a sample app that uses the latest NuGet package and doesn't just throw compilation errors?

All of the samples are using version 2.3.4.224.

Static Image and Progress bar using Storyboard

$
0
0

Hi,

I have a basic question please..

I need to have a Launch image for my iOS which will have an image and a progress bar only

I am able to place both but having difficulties positioning them

I want to position the image to be full screen for Any device and the progress bar to be on it like below

How can I do that please..

Thanks,
Jassim

ImageSource.FromResource not working for me in UWP

$
0
0

Hi,
I am using some embedded images in a Net Standard class library. They are set to "Embedded Resource" and in a folder "Images". I am accessing them with:
FileImg = ImageSource.FromResource("MyApp.Images.logo.png");

It works fine in Droid and iOS but in UWP, FileImg = null.

The xaml is:
<Image Source="{Binding FileImg}" VerticalOptions="Start" HorizontalOptions="Center" WidthRequest="256" HeightRequest="125" />

Any insight is appreciated!


Button with an image, how to centre the image horizontally?

$
0
0

Hi guys,
Trying to get a little button with an image, I want the image to be centred within the button but it is always to the left.

        Button button = new Button();
        {
            //WidthRequest = 50
            BorderWidth = 0.5,
            BorderColor = Color.Gray,
            HorizontalOptions = LayoutOptions.Center,
            VerticalOptions = LayoutOptions.CenterAndExpand
        };
        button = (FileImageSource) ImageSource.FromFile("Images/image1.png");

Also strangely enough, the image is displaying in blue. The image is mostly gray...

IOS frame background color and TabBar color not accurate?

$
0
0

Working on a cross platform forms project, and most of my code is shared.
As you can see on the picture the android version shows the colors as expected but the IOS version seems to change the opacity or saturation or something.

The Items with weird color change are the tab bar background and the frame background on the IOS version.

Here is the definition of the frame: (the content is an Image and the card.color matches the images background color)
Frame frame = new Frame { Content = block, HeightRequest = 77, BackgroundColor = card.color, Padding = 10, Margin = 2, OutlineColor = Color.Gray, HasShadow = false, }

For the tab bar i just added this on the TabbedPage :
this.BarBackgroundColor = card.color;

I tested messing around with the UITabBar in the AppDelegate like this
UITabBar.Appearance.BarTintColor = UIColor.Clear;

Of course it didn't work.

Sorry for all the blurriness (Not sure whats NDA protected so I'm playing safe)
And sorry if my English is broken.

So my question:
-Why is this happening?

What I really want to know:
-How can i fix this?

Bonus question:
-Why does IOs hate me so much?

All my code is c# because markup languages make me cry. Let me know if more details are needed.

PS: Its my first time with xamarin, please be gentle.

Plugin.Media and retake photos

$
0
0

Hi guys,
I'm using MediaPlugin. I've never had a problem but today.

Scenario
The user can take a picture and send it via email.

Issue
If the user is in the camera and retakes a photo (ones or multiple times), iOS and Android create a new picture with the same name +"_" and a number. When I add the path of the original images, in the email all images are attached.

For example, the image has name "pippo". In the filesystem I found "pippo_1", "pippo_2", I add in the email only "pippo" but there are three attachments.

CarouselView is throwing dividebyzeroezception when i run the android version.

$
0
0

Hi, am developing a xamarin.Forms application and am using carousel view. it is working fine in iOS version but when i run the android version it is throwing dividebyzero exception. When i comment the CarouselView code in xaml it is not throwing any exception, it is running fine in android as well.Am using Xamarin.Forms.CarouselView nuget package version 2.3.0 pre-2. Can someone please help me out to solve this issue.
below is the code am using it in xaml


                        <BoxView Style="{DynamicResource BoxViewDefaultStyle}" />
                        <AbsoluteLayout
                HorizontalOptions="Fill"
                VerticalOptions="Fill">
                        <StackLayout Padding="15,10,15,5" Spacing="3"
                               AbsoluteLayout.LayoutBounds="0,0,1,1"
                 AbsoluteLayout.LayoutFlags="All"
                 BackgroundColor="{DynamicResource OverlayBackgroundColor}" Orientation="Vertical">
                                                   <Image Source="Ico.png" WidthRequest="35" HeightRequest="35" HorizontalOptions="Center" />

                               <cv:CarouselView Position="{Binding StartPosition, Mode=TwoWay}" ItemsSource="{Binding Data}" HeightRequest="44">
                                    <cv:CarouselView.ItemTemplate>
                                        <DataTemplate>

                                                <Label TextColor="{DynamicResource LightTextColor}" LineBreakMode="WordWrap" FontSize="Micro" VerticalOptions="CenterAndExpand"
                                                    Text="{Binding Text}" />

                                        </DataTemplate>
                                    </cv:CarouselView.ItemTemplate>
                                </cv:CarouselView>

                            <controls:CarouselIndicators HorizontalOptions="CenterAndExpand" IndicatorHeight="8" IndicatorWidth="8" UnselectedIndicator="IcoCarouselIndicatorUnselectedLightGray.png" SelectedIndicator="IcoCarouselIndicatorSelectedLightGray.png"
                                                     Position="{Binding StartPosition, Mode=TwoWay}" ItemsSource="{Binding Data}" />
                        </StackLayout>
                             </AbsoluteLayout>
                        <BoxView Style="{DynamicResource BoxViewDefaultStyle}" />



                </StackLayout>

Thanks in advance.

Problem with XAML x:Name and access from code-behind

$
0
0

Hi all.

I'm new to Xamarin Forms and have made a Xamarin Forms PCL project and added a few pages to it. So far the app is compiling and running fine on my samsung galaxy s5. :D But when a make a new Entry tag in the xaml file and give it a x:Name so that i can access it from code-behind, i can't, i need to restart Xamarin Studio to access it and se all the methods and properties is has. I have tried to search google for a similar problem, but with no luck.
So my question is, does someone know how to solve this problem? As far as i know, it has something to do with a g.cs file no being generated.

My system is a Macbook Air fully updated, and with Xamarin Studio 5.5, and i have a indie license for android.

Kind regards
Steffen

Viewing all 77050 articles
Browse latest View live


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