Forum Xamarin.Android

AndroidX Samples

genifygenify Member ✭✭

Where can we find a sample Xamarin/Android app using AndroidX for Minimum Android version API level 28 with NO backward support needed.

This is really a nightmare. The migration tool has totally broken the app and I had no backward compatible libraries loaded.

Currently it cannot locate the styles in styles.xml with no indication of why.

I need to know what AndroidX libraries to load for a simple app.

Anyone have this working?

Tagged:

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Sorry,I am confused with what you said.

    NO backward support needed

    Currently it cannot locate the styles in styles.xml with no indication of why.

    Could you please elaborate on your problem?

  • genifygenify Member ✭✭

    Concrete example just using the base unmodified App template

    With Visual Studio 2019 Version 16.5.2

    • Created a new application for Android App (Xamarin).
    • Minimum Android Version Android 9.0 (Pie).
    • Single View App

    Despite this being an Android 9.0 application,
    MainActivity is created as a subclass of AppCompatActivity not Activity.

    Older support libraries are included
    using Android.Support.V7.App;

    The toolbar is created as:

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
    

    Migrate to AndroidX caused the following change:

    FROM:





    TO:






    BUILD NOW FAILS

    1>C:\Dev\Projects\AITC\AndroidApps\App1\App1\MainActivity.cs(6,23,6,25): error CS0234: The type or namespace name 'V7' does not exist in the namespace 'Android.Support' (are you missing an assembly reference?)
    1>C:\Dev\Projects\AITC\AndroidApps\App1\App1\MainActivity.cs(14,33,14,50): error CS0246: The type or namespace name 'AppCompatActivity' could not be found (are you missing a using directive or an assembly reference?)
    1>C:\Dev\Projects\AITC\AndroidApps\App1\App1\MainActivity.cs(17,33,17,41): error CS0115: 'MainActivity.OnCreate(Bundle)': no suitable method found to override
    1>C:\Dev\Projects\AITC\AndroidApps\App1\App1\MainActivity.cs(30,30,30,49): error CS0115: 'MainActivity.OnCreateOptionsMenu(IMenu)': no suitable method found to override
    1>C:\Dev\Projects\AITC\AndroidApps\App1\App1\MainActivity.cs(36,30,36,51): error CS0115: 'MainActivity.OnOptionsItemSelected(IMenuItem)': no suitable method found to override
    1>C:\Dev\Projects\AITC\AndroidApps\App1\App1\MainActivity.cs(53,30,53,56): error CS0115: 'MainActivity.OnRequestPermissionsResult(int, string[], Permission[])': no suitable method found to override
    1>
    1>Build FAILED.

  • genifygenify Member ✭✭

    Migrate to AndroidX caused the following change:

    FROM:

    • PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3"
    • PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3"
    • PackageReference Include="Xamarin.Android.Support.CustomTabs" Version="28.0.0.3"
    • PackageReference Include="Xamarin.Essentials" Version="1.3.1"

    TO:

    • PackageReference Include="Xamarin.Google.Android.Material" Version="1.0.0-preview02"
    • PackageReference Include="Xamarin.AndroidX.Legacy.Support.Core.Utils" Version="1.0.0-preview02"
    • PackageReference Include="Xamarin.AndroidX.Browser" Version="1.0.0-preview02"
    • PackageReference Include="Xamarin.Essentials" Version="1.3.1"
    • PackageReference Include="Xamarin.AndroidX.Migration" Version="1.0.0-preview03"

    BUILD NOW FAILS

Sign In or Register to comment.