xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 506 forks source link

Can't compile Xamarin.Essentials while targeting Android SDK v34 #2121

Closed nisewonder closed 6 months ago

nisewonder commented 6 months ago

Bug report best practices: Submitting Issues

Description

This issue was related to an AndroidX.Core NuGet package. Removing that package resolved the issue.

Visual Studio v17.8.5, Android Xamarin.Forms application.
Xamarin.Essentials = v1.8.1 Target Framework = Android 13.0 manually set targetSdkVersion = 34 in the Android manifest file The following error is reported while building in "Debug" mode:

3>C:\fltools\Platforms\Xamarin.Forms\Tools\FieldLogicToolsXF.Android\obj\Debug\130\android\src\xamarin\essentials\fileProvider.java(29,3): javac.exe error JAVAC0000: error: constructor FileProvider in class FileProvider cannot be applied to given types; 3>C:\fltools\Platforms\Xamarin.Forms\Tools\FieldLogicToolsXF.Android\obj\Debug\130\android\src\xamarin\essentials\fileProvider.java(29,3): javac.exe error JAVAC0000: super (p0); 3>C:\fltools\Platforms\Xamarin.Forms\Tools\FieldLogicToolsXF.Android\obj\Debug\130\android\src\xamarin\essentials\fileProvider.java(29,3): javac.exe error JAVAC0000: required: no arguments 3>C:\fltools\Platforms\Xamarin.Forms\Tools\FieldLogicToolsXF.Android\obj\Debug\130\android\src\xamarin\essentials\fileProvider.java(29,3): javac.exe error JAVAC0000: found: int 3>C:\fltools\Platforms\Xamarin.Forms\Tools\FieldLogicToolsXF.Android\obj\Debug\130\android\src\xamarin\essentials\fileProvider.java(29,3): javac.exe error JAVAC0000: reason: actual and formal argument lists differ in length

There is no compile error when building in "Release" mode. A 2nd "Debug" mode build shows no errors. Attempting to deploy a "Deubg" build always results in the error.

While attempting to deploy and debug the following error is generated: C:\Program Files (x86)\Android\openjdk\jdk-17.0.8.101-hotspot\bin\javac.exe -J-Dfile.encoding=UTF8 "@C:\Users\jason.nisewonder\AppData\Local\Temp\tmp77A0.tmp" -target 1.8 -source 1.8 obj\Debug\130\android\src\xamarin\essentials\fileProvider.java:29: error: constructor FileProvider in class FileProvider cannot be applied to given types; super (p0); ^ required: no arguments found: int reason: actual and formal argument lists differ in length Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error JAVAC0000: error: constructor FileProvider in class FileProvider cannot be applied to given types; super (p0); required: no arguments found: int reason: actual and formal argument lists differ in length

Done building project "XXXXXXXXXXXXXX.Android.csproj" -- FAILED. 3>Deployment failed to Google Pixel 7. Build FAILED.

Steps to Reproduce

  1. Set Android targetSdkVersion = 34 in the Android manifest file
  2. Compile using Android version (target framework) = Android 13.0
  3. Install Xamarin.Essentials 1.8.1
  4. Attempt to build an Android Xamarin.Forms application in "Debug" mode

    Expected Behavior

    Build succeeds

    Actual Behavior

    Build fails

    Basic Information

Screenshots

Reproduction Link

nisewonder commented 6 months ago

This issue was related to an AndroidX.Core NuGet package. Removing that package resolved the issue.