baskren / Forms9Patch

Simplify image management and text formatting in your Xamarin.Forms apps
http://Forms9Patch.com
Other
128 stars 33 forks source link

[Bug] Can not resolve reference Xamarin.AndroidX.Loader, referenced by Forms9Patch.droid please add Nuget package or assembly reference for xamarin.AndroidX.Loader #73

Closed danypepin1 closed 4 years ago

danypepin1 commented 4 years ago

Description

I want to print from my xamarin.forms app, i found this on internet so i wanted to try it.

When i build i get this : Can not resolve reference Xamarin.AndroidX.Loader, referenced by Forms9Patch.droid please add Nuget package or assembly reference for xamarin.AndroidX.Loader

i added the Forms(Patch.Droid.Settings.Initialize(this); to my MainActivity.cs :+1:

Xamarin.Forms.Forms.SetFlags(new string[] { "Expander_Experimental", "SwipeView_Experimental" }); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); XamForms.Controls.Droid.Calendar.Init(); Forms9Patch.Droid.Settings.Initialize(this); LoadApplication(new App());

In my xaml page i have a button that i want to click to print:

<Button Text="Imprimer" TextColor="#008A00" BackgroundColor="#FFFFFF" BorderWidth="1" BorderColor="#1A961A" Clicked="PrintButtonClicked"></Button>

in the xaml.cs i added the : using Forms9Patch;

and i have my function :

` private void PrintButtonClicked(object sender, EventArgs e) { var myHtmlString = @" <!DOCTYPE html>

Convert to PNG

This html will be converted to a PNG, PDF, or print.

                        ";
        myHtmlString.PrintAsync("my_print_job_name");
    }
        `

I try to build and get the error above, i tried to install Xamarin.AndroidX.Loader nuget but still get the same error, im kinda confused. Thanks

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

Screenshots

Reproduction Link - a link to a small demo project that reproduces this issue

Workaround

baskren commented 4 years ago

There are a dozen possible reasons this could be happening. Without a demo project (reproduction link), the only guess I have is from what you've shared:

Can not resolve reference Xamarin.AndroidX.Loader, referenced by Forms9Patch.droid please add Nuget package or assembly reference for xamarin.AndroidX.Loader

Did you add Xamarin.AndroidX.Loader NuGet package to your Android platform project?

danypepin1 commented 4 years ago

Sorry, i didn't even notice that my xamarin.AndroidX.Loader installation failed in the first place.

But yea the installation failed ( sorry it's in french but : n'est pas compatible means it's not compatible )

so you cannot use this with netstandard 2.0 ?

Restauration des packages pour C:\Users\DPE142\source\repos\Calculette\Calculette\Calculette\Calculette.csproj... NU1202: Le package Xamarin.AndroidX.Loader 1.1.0.1 n'est pas compatible avec netstandard2.0 (.NETStandard,Version=v2.0). Le package Xamarin.AndroidX.Loader 1.1.0.1 prend en charge : monoandroid90 (MonoAndroid,Version=v9.0) Restauration des packages pour C:\Users\DPE142\source\repos\Calculette\Calculette\Calculette.iOS\Calculette.iOS.csproj... NU1202: Le package Xamarin.AndroidX.Loader 1.1.0.1 n'est pas compatible avec xamarinios10 (Xamarin.iOS,Version=v1.0). Le package Xamarin.AndroidX.Loader 1.1.0.1 prend en charge : monoandroid90 (MonoAndroid,Version=v9.0) NU1202: Le package Xamarin.AndroidX.Loader 1.1.0.1 n'est pas compatible avec xamarinios10 (Xamarin.iOS,Version=v1.0) / win. Le package Xamarin.AndroidX.Loader 1.1.0.1 prend en charge : monoandroid90 (MonoAndroid,Version=v9.0) NU1202: Le package Xamarin.AndroidX.Loader 1.1.0.1 n'est pas compatible avec xamarinios10 (Xamarin.iOS,Version=v1.0) / win-x64. Le package Xamarin.AndroidX.Loader 1.1.0.1 prend en charge : monoandroid90 (MonoAndroid,Version=v9.0) NU1202: Le package Xamarin.AndroidX.Loader 1.1.0.1 n'est pas compatible avec xamarinios10 (Xamarin.iOS,Version=v1.0) / win-x86. Le package Xamarin.AndroidX.Loader 1.1.0.1 prend en charge : monoandroid90 (MonoAndroid,Version=v9.0) Restauration des packages pour C:\Users\DPE142\source\repos\Calculette\Calculette\Calculette.Android\Calculette.Android.csproj... Échec de la restauration du package. Restauration des modifications du package pour 'Calculette'.

baskren commented 4 years ago

Nope. It has to be installed into your Android project, not your .NetStandard project. This also means your Android project needs to be built for AndroidX (as opposed to the old way of doing it).

https://docs.microsoft.com/en-us/xamarin/android/platform/androidx

If you have an older Android platform project, then I would recommend using the AndroidX migration tool (in VisualStudio - see the above doc).

Also note that I've often struggled to get AndroidX packages to upgrade (once they are installed) or was unable to install because the existing installed AndroidX packages are down level. To work around this, I've manually updated the version numbers (using VisualStudio Code, for example) in the Android platform project's .csproj file. Then, I've reloaded the solution in VisualStudio.

danypepin1 commented 4 years ago

Ok sorry for disturbing you, i'm new to this and didn't know this even existed haha. Thanks for the answer, have a good day !

baskren commented 4 years ago

Il ne pas de quoi