Closed kablammyman closed 4 months ago
If it's the same problem, there is an issue in other packages. Try to install these packages to solve your issue:
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.1" />
I was only able to install Xamarin.AndroidX.Collection and Xamarin.AndroidX.Collection.Ktx with their latest version when installing your nuget package. Using 1.3.0.1 versions lead to this warning as error:
Error NU1605 Warning As Error: Detected package downgrade: Xamarin.AndroidX.Collection from 1.3.0.2 to 1.3.0.1. Reference the package directly from the project to select a different version.
LandInvestingApp -> Plugin.MauiMTAdmob 1.4.2 -> Xamarin.AndroidX.Collection (>= 1.3.0.2)
LandInvestingApp -> Xamarin.AndroidX.Collection (>= 1.3.0.1) LandInvestingApp D:\source\LandInvestingApp\LandInvestingApp.csproj 1
Anyway, when I had both Xamarin.AndroidX.Collection packages and your MTAdmob package installed, I got the same error when building the code. This is just installing the package, I didnt even need to add any code to my project to get the compiler errors
My bad...use this:
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.3.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.2" />
The version is important.
In the .net7 I also needed to install the following:
<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.8.2" />
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.8.2" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.6.2.3" />
You can see all of them in the Sample projects.
Unfortunately using version 1.3.0.2 with your nuget package did not help...same error. here are my packages:
[net8.0-android34.0]:
Top-level Package Requested Resolved
> CommunityToolkit.Maui 8.0.1 8.0.1
> CommunityToolkit.Maui.Maps 2.0.1 2.0.1
> CommunityToolkit.Maui.MediaElement 3.1.0 3.1.0
> CommunityToolkit.Mvvm 8.2.2 8.2.2
> CSCore 1.2.1.2 1.2.1.2
> Geocoding.Microsoft 4.0.1 4.0.1
> Microsoft.Extensions.Logging.Console 8.0.0 8.0.0
> Microsoft.Extensions.Logging.Debug 8.0.0 8.0.0
> Microsoft.Maui.Controls 8.0.21 8.0.21
> Microsoft.Maui.Controls.Compatibility 8.0.21 8.0.21
> Microsoft.Maui.Controls.Maps 8.0.21 8.0.21
> Microsoft.Maui.Essentials 8.0.21 8.0.21
> Microsoft.Maui.Extensions 6.0.553 6.0.553
> Microsoft.NET.ILLink.Tasks (A) [8.0.4, ) 8.0.4
> NAudio 2.2.1 2.2.1
> NAudio.Lame 2.1.0 2.1.0
> Newtonsoft.Json 13.0.3 13.0.3
> OneSignalSDK.DotNet 5.1.2 5.1.2
> Plugin.LocalNotification 11.1.2 11.1.2
> Plugin.Maui.Audio 2.1.0 2.1.0
> Plugin.MauiMTAdmob 1.4.2 1.4.2
> Xamarin.AndroidX.Collection 1.3.0.2 1.3.0.2
> Xamarin.AndroidX.Collection.Ktx 1.3.0.2 1.3.0.2
Could you please copy the code to include the packages from the csproj file? So I can quickly include them in a sample project and check the error.
Im not sure what you mean, do you need a copy of my csproj file, or are you looking to get my whole project? The whole project cant be shared.
Just the part of the csproj file with your packages:
like this one:
<ItemGroup>
...
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
...
</ItemGroup>
ah okay, here ya go
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui.Maps" Version="2.0.1" />
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="3.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CSCore" Version="1.2.1.2" />
<PackageReference Include="Geocoding.Microsoft" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Extensions" Version="6.0.553" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="NAudio.Lame" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OneSignalSDK.DotNet" Version="5.1.2" />
<PackageReference Include="Plugin.LocalNotification" Version="11.1.2" />
<PackageReference Include="Plugin.Maui.Audio" Version="2.1.0" />
<PackageReference Include="Plugin.MauiMTAdmob" Version="1.4.2" />
</ItemGroup>
The incompatibility is between OneSignalSDK.DotNet and Plugin.MauiMTAdmob.
I'm trying to investigate the issue and find a solution
Solved!
This is a known issues with AndroidX, you need to manually import the following packages (Maybe not all are needed):
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.9.0.1" />
<PackageReference Include="Xamarin.AndroidX.Work.Work.Runtime.Ktx" Version="2.9.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.8.2.1" />
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.8.2.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.7.0.1" />
</ItemGroup>
Add then to your csproj and the project will compile again.
I have this now in my csproj file:
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.1" />
<PackageReference Include="CommunityToolkit.Maui.Maps" Version="2.0.1" />
<PackageReference Include="CommunityToolkit.Maui.MediaElement" Version="3.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CSCore" Version="1.2.1.2" />
<PackageReference Include="Geocoding.Microsoft" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.21" />
<PackageReference Include="Microsoft.Maui.Extensions" Version="6.0.553" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="NAudio.Lame" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OneSignalSDK.DotNet" Version="5.1.2" />
<PackageReference Include="Plugin.LocalNotification" Version="11.1.2" />
<PackageReference Include="Plugin.Maui.Audio" Version="2.1.0" />
<PackageReference Include="Plugin.MauiMTAdmob" Version="1.4.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android'">
<PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.9.0.1" />
<PackageReference Include="Xamarin.AndroidX.Work.Work.Runtime.Ktx" Version="2.9.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.0.1" />
<PackageReference Include="Xamarin.AndroidX.Activity" Version="1.8.2.1" />
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.8.2.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.7.0.1" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.7.0.1" />
</ItemGroup>
Did I make the proper changes? What I have in my csproj file did not fix the errors.
Am I supposed to uninstall the AndroidX packages in nuget before making these changes to the proj file? I only made the change and didnt uninstall anything.
Clean your project, remove the bin and obj folders, and make sure that in your csproj you have
<TargetFrameworks>...net8.0-android...</TargetFrameworks>
Otherwise adjust the condition of your ItemGroup and that should work
Okay, it worked! thank you for looking into this!
Hello, when I install the MAUI MtAdmob nuget package, I started to get compile time errors for my android build. (i have not tested the iOS version yet)
These errors happen even when I dont have any code to utilize the nuget package.
Im wondering if there is some sort of conflict with the other packages I use, since Im using onesignal for push notifications...and that uses firebase\google code.
Anyway, here is the error I get:
Here are the packages in my project: