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

Android: JAVAC : warning : [options] source value 8 is obsolete and will be removed in a future release #9925

Open
SteveBush opened this issue Mar 14, 2025 · 21 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@SteveBush
Copy link

SteveBush commented Mar 14, 2025

Description

After installing latest OpenJDK and Android workload, I now get the following warning when building the default Maui template:

d:\Github\Temp>dotnet build
Restore complete (0.6s)
  Temp net9.0-ios succeeded (1.4s) → bin\Debug\net9.0-ios\iossimulator-x64\Temp.dll
  Temp net9.0-maccatalyst succeeded (1.5s) → bin\Debug\net9.0-maccatalyst\maccatalyst-x64\Temp.dll
  Temp net9.0-windows10.0.19041.0 succeeded (8.4s) → bin\Debug\net9.0-windows10.0.19041.0\win10-x64\Temp.dll
  Temp net9.0-android succeeded with 3 warning(s) (35.4s) → bin\Debug\net9.0-android\Temp.dll
    JAVAC : warning : [options] source value 8 is obsolete and will be removed in a future release
    JAVAC : warning : [options] target value 8 is obsolete and will be removed in a future release
    JAVAC : warning : [options] To suppress warnings about obsolete options, use -Xlint:-options.

Build succeeded with 3 warning(s) in 36.9s

Warnings also appear in Visual Studio.
Building with openjdk version "21.0.6" 2025-01-21 LTS
Maui Android workload: 35.0.50/9.0.100 SDK 9.0.200, VS 17.13.35828.75

Steps to Reproduce

  1. Create a new directory called Temp
  2. dotnet new maui
  3. dotnet build

Link to public reproduction project repository

No response

Version with bug

9.0.50 SR5

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.40 SR4

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

No response

Relevant log output

d:\Github\NetworkVisor\Temp>dotnet workload list

Installed Workload Id      Manifest Version       Installation Source
--------------------------------------------------------------------------------
android                    35.0.50/9.0.100        SDK 9.0.200, VS 17.13.35828.75
aspire                     8.2.2/8.0.100          SDK 9.0.200, VS 17.13.35828.75
ios                        18.2.9180/9.0.100      SDK 9.0.200, VS 17.13.35828.75
maccatalyst                18.2.9180/9.0.100      SDK 9.0.200, VS 17.13.35828.75
macos                      15.2.9180/9.0.100      SDK 9.0.200, VS 17.13.35828.75
maui-windows               9.0.14/9.0.100         SDK 9.0.200, VS 17.13.35828.75
tvos                       18.2.9180/9.0.100      SDK 9.0.200, VS 17.13.35828.75
wasm-tools                 9.0.3/9.0.100          SDK 9.0.200, VS 17.13.35828.75
wasm-tools-net6            9.0.3/9.0.100          SDK 9.0.200, VS 17.13.35828.75
wasm-tools-net7            9.0.3/9.0.100          SDK 9.0.200, VS 17.13.35828.75
wasm-tools-net8            9.0.3/9.0.100          SDK 9.0.200, VS 17.13.35828.75

java -version
openjdk version "21.0.6" 2025-01-21 LTS
OpenJDK Runtime Environment Microsoft-10800203 (build 21.0.6+7-LTS)
OpenJDK 64-Bit Server VM Microsoft-10800203 (build 21.0.6+7-LTS, mixed mode, sharing)
@jfversluis jfversluis transferred this issue from dotnet/maui Mar 17, 2025
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Mar 17, 2025
@jpobst jpobst added Area: App+Library Build Issues when building Library projects or Application projects. and removed needs-triage Issues that need to be assigned. t/bug labels Mar 17, 2025
@pininfarino
Copy link

I have same problem.

Build android 35 build with Azure devops mac-os instance

Image

@dellis1972
Copy link
Contributor

Can someone provide a diagnostic build log which contains the issue . See aka.ms/binlog for details on how to get the required data.

@dellis1972 dellis1972 added the need-info Issues that need more information from the author. label Mar 18, 2025
@SteveBush
Copy link
Author

msbuild.zip

@dotnet-policy-service dotnet-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Mar 18, 2025
@dellis1972
Copy link
Contributor

looks like this was fixed in 165cef7.
4 month ago. Not sure if it has been released yet though. @jonathanpeppers ?

@jpobst
Copy link
Contributor

jpobst commented Mar 18, 2025

Note we also have #9922 which says we need these values, so we'll have to figure out a solution that addresses both issues.

@jpobst jpobst removed the need-attention A xamarin-android contributor needs to review label Mar 18, 2025
@SteveBush
Copy link
Author

Do you have any updates on fix timing or suggestions for workarounds? Unfortunately, I haven't figured out how to ignore this error in my nightly build pipelines.

@jpobst
Copy link
Contributor

jpobst commented Mar 19, 2025

This is just a warning, it is not an error. It is safe to ignore it.

Your build is still succeeding:

Build succeeded with 3 warning(s) in 36.9s

You might be able to make the warning go away by adding this to your project file:

  <PropertyGroup>
    <JavacSourceVersion>17</JavacSourceVersion>
    <JavacTargetVersion>17</JavacTargetVersion>
  </PropertyGroup>

@SteveBush
Copy link
Author

I should have mentioned this earlier. I have tried adding the Java Compiler version properties to global prop and target files and the MAUI app project and the warning is still generated.

My nightly builds have treat warnings as errors on so they fail with any build warnings. I haven’t figure out any way to suppress these warnings.

@jpobst
Copy link
Contributor

jpobst commented Mar 19, 2025

Weird, it seems like we would only set the defaults if they hadn't already been set elsewhere:

<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' ">1.8</JavacSourceVersion>
<JavacTargetVersion Condition=" '$(JavacTargetVersion)' == '' ">1.8</JavacTargetVersion>

I think if you pass them on the command line then they become global properties and cannot be overwritten:

dotnet build -p:JavacSourceVersion=17 -p:JavacTargetVersion=17

@dellis1972
Copy link
Contributor

The alternative is to set environment variables, they also cannot be overwritten.

@jonpryor
Copy link
Member

@dellis1972: I suspect that this issue is already addressed by:

  • 165cef7: bumps $(JavacSourceVersion) and $(JavacTargetVersion) to 17

Perhaps we need to bring it over?

@pininfarino
Copy link

Has anyone managed to fix this?
Please @jfversluis

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Apr 3, 2025

Has anyone managed to fix this?

@pininfarino are you just wanting to hide the warning? or does this cause some other problem? You should be able to use regular MSBuild features to hide the warning like $(WarningsAsMessages).

Is the problem gone in .NET 10 previews?

@SteveBush
Copy link
Author

For me, the problem breaks my CI builds as I have treat warnings as errors turned on. The problem occurs during the signing of the Android package. I haven’t managed to find a fix for this.

@jonathanpeppers
Copy link
Member

I can't tell from the text log above; if the warning has an error code. Does it have JAVA0000? If so, you'd do this in your .csproj:

<PropertyGroup>
  <WarningsAsMessages>$(WarningsAsMessages);JAVA0000</WarningsAsMessages>

This should be fine, as JAVA0000 errors would still show an error.

There is no .binlog attached, if we had one we could tell for sure: https://aka.ms/binlog

@SteveBush
Copy link
Author

I have not been able to find a solution to prevent the Java error from being outputted as a warning. I think it happens during the Android signing process. I put the following in my solution props file, but it didn't work.

I have created a new MAUI project and run dotnet build -bl. Binary logs are zipped below.

<WarningsAsMessages>$(WarningsAsMessages);JAVA0000</WarningsAsMessages>

d:\Github\NetworkVisor\Temp>dotnet build -bl
Restore complete (1.4s)
  Temp net9.0-maccatalyst succeeded (3.0s) → bin\Debug\net9.0-maccatalyst\maccatalyst-x64\Temp.dll
  Temp net9.0-ios succeeded (3.1s) → bin\Debug\net9.0-ios\iossimulator-x64\Temp.dll
  Temp net9.0-windows10.0.19041.0 succeeded (9.1s) → bin\Debug\net9.0-windows10.0.19041.0\win10-x64\Temp.dll
  Temp net9.0-android succeeded with 3 warning(s) (37.6s) → bin\Debug\net9.0-android\Temp.dll
    JAVAC : warning : [options] source value 8 is obsolete and will be removed in a future release
    JAVAC : warning : [options] target value 8 is obsolete and will be removed in a future release
    JAVAC : warning : [options] To suppress warnings about obsolete options, use -Xlint:-options.

Build succeeded with 3 warning(s) in 39.9s

Build Log: msbuild.zip

@jonathanpeppers
Copy link
Member

Ok, so it looks like MSBuild's ToolTask is seeing message from stdout like:

JAVAC [options] source value 8 is obsolete and will be removed in a future release

Then decides it is a warning, but it logs without an error code if it doesn't "parse" one from the message:

It does seem like you should be able to set $(JavacSourceVersion) and $(JavacTargetVersion) to 17, as they are only set if blank:

<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' ">1.8</JavacSourceVersion>
<JavacTargetVersion Condition=" '$(JavacTargetVersion)' == '' ">1.8</JavacTargetVersion>

Do you have a .binlog where you tried that?

@SteveBush
Copy link
Author

I try adding the following to my csproj file.

	<PropertyGroup>
		<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' ">17</JavacSourceVersion> 
		<JavacTargetVersion Condition=" '$(JavacTargetVersion)' == '' ">17</JavacTargetVersion> 
	</PropertyGroup>

I get the following result:

d:\Github\NetworkVisor\Temp>dotnet build -bl
Restore complete (0.6s)
  Temp net9.0-maccatalyst succeeded (3.1s) → bin\Debug\net9.0-maccatalyst\maccatalyst-x64\Temp.dll
  Temp net9.0-ios succeeded (3.2s) → bin\Debug\net9.0-ios\iossimulator-x64\Temp.dll
  Temp net9.0-windows10.0.19041.0 succeeded (8.6s) → bin\Debug\net9.0-windows10.0.19041.0\win10-x64\Temp.dll
  Temp net9.0-android failed with 2 error(s) (16.4s) → bin\Debug\net9.0-android\Temp.dll
    JAVAC : error : option --boot-class-path cannot be used together with --release
    C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.50\tools\Xamarin.Android.Javac.targets(161,5): error XAJVC0000:
      error: option --boot-class-path cannot be used together with --release
      Usage: javac <options> <source files>
      use --help for a list of possible options

Build failed with 2 error(s) in 18.0s

Update .binlog
msbuild.zip

@jonathanpeppers
Copy link
Member

Ok, so other parameters also would need to be changed with -source 17 -target 17, so the only thing we can really do is bring this to .NET 9:

@pininfarino
Copy link

@jonathanpeppers
Thanks for the answer,
it annoys me on Azure Devops mac-os

  • for build android
  • I don't want to hide it, I know how to do it.
  • But I looked, I saw that you already did it
    => Thank you very much
    I'll try it again if possible

@SteveBush
Copy link
Author

@jonathanpeppers Thanks for the answer, it annoys me on Azure Devops mac-os

  • for build android
  • I don't want to hide it, I know how to do it.
  • But I looked, I saw that you already did it
    => Thank you very much
    I'll try it again if possible

Same here. I had to disable my Maui CI builds as I couldn't figure out a way to suppress the warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

No branches or pull requests

6 participants