Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MAUI (Android) Support? #1618

Open
johnjore opened this issue Oct 2, 2024 · 3 comments
Open

Add MAUI (Android) Support? #1618

johnjore opened this issue Oct 2, 2024 · 3 comments
Labels
help wanted Extra attention is needed new feature

Comments

@johnjore
Copy link

johnjore commented Oct 2, 2024

Is your feature request related to a problem? Please describe.
Upgraded my Xamarin.Android project to MAUI (MAUI.Android?) and can't seem to use LiveCharts2 in a MAUI.Android project

Describe the solution you'd like
Is it possible to add support for MAUI.Android?

Additional context
Extract from project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-android</TargetFramework>

Small extract from XML (Resources/layout):

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:card_view="http://schemas.android.com/apk/res-auto"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content">

    <androidx.cardview.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardElevation="4dp"
        card_view:cardCornerRadius="5dp"
        card_view:cardUseCompatPadding="true">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="8dp">

            <ImageView
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:scaleType="fitXY"
                android:id="@+id/GPXTypeLogo"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:layout_gravity="left"
                android:contentDescription="@string/type"
                android:layout_marginLeft="@dimen/layout_marginLeft" />

            <CartesianChart
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/TrackRouteMap"
                android:id="@+id/TrackRouteElevation"
                android:scaleType="fitCenter"
                android:layout_marginLeft="@dimen/layout_marginLeft"
                android:layout_marginTop="-10dp"
                android:visibility="visible" />

Extract while setting up the RecyclerView:

        public ImageView? TrackRouteMap { get; set; }
        public CartesianChart? TrackRouteElevation { get; set; }

        public GPXViewHolder(Android.Views.View itemview, Action<int> listener) : base(itemview)
        {
            GPXTypeLogo = itemview?.FindViewById<ImageView>(Resource.Id.GPXTypeLogo);
            Name = itemview?.FindViewById<TextView>(Resource.Id.Name);
            Distance = itemview?.FindViewById<TextView>(Resource.Id.Distance);
            Ascent = itemview?.FindViewById<TextView>(Resource.Id.Ascent);
            Descent = itemview?.FindViewById<TextView>(Resource.Id.Descent);
            Img_more = itemview?.FindViewById<TextView>(Resource.Id.textViewOptions);
            TrackRouteMap = itemview?.FindViewById<ImageView>(Resource.Id.TrackRouteMap);
---> Fails with error below:
            TrackRouteElevation = itemview?.FindViewById<CartesianChart>(Resource.Id.TrackRouteElevation);
        }


Severity	Code	Description	Project	File	Line	Suppression State	Details
Error (active)	CS0311	The type 'LiveChartsCore.SkiaSharpView.Maui.CartesianChart' cannot be used as type parameter 'T' in the generic type or method 'View.FindViewById<T>(int)'. There is no implicit reference conversion from 'LiveChartsCore.SkiaSharpView.Maui.CartesianChart' to 'Android.Views.View'.	hajk	hajk\GPX\GPX.cs

@beto-rodriguez
Copy link
Owner

Hi

I am sorry, I never used Xamarin Android nor Xamarin iOS, can you help me with a minimal reproducible sample, then I can fix this much faster.

@tjorvenK
Copy link

tjorvenK commented Oct 9, 2024

Hi, I just stumbled upon your issue. I am using livecharts with maui and android. If you could provide some more information, maybe a small sample project, I could also be of help

@johnjore
Copy link
Author

johnjore commented Oct 10, 2024

I ended up using oxyplot instead, at least for now. I'll try and find some time to create a mini project, but its essentially a .NET Android Application as defined in the VS templates:

image

In the olden days, this would probably have been called Xamarin.Android (as opposed to Xamarin.Forms, which is now MAUI)

@beto-rodriguez beto-rodriguez added help wanted Extra attention is needed new feature labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed new feature
Projects
None yet
Development

No branches or pull requests

3 participants