dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.92k stars 526 forks source link

Build task GetJavaPlatformJar occasionally fails to set JavaPlatformJarPath, causing later tasks to fail #9285

Closed MSLukeWest closed 1 week ago

MSLukeWest commented 2 weeks ago

Android framework version

net9.0-android

Affected platform version

9.0.100-preview.7.24407.12

Description

Occasionally when I have my MAUI project open in Visual Studio, I see this error in the error list:

MSB4044: The "GenerateRtxt" task was not given a value for the required parameter "JavaPlatformJarPath"

I took a look at the .binlog file, and I see that the problem is that the GetJavaPlatformJar task that runs earlier is failing to set the JavaPlatformJarPath property.

image

Steps to Reproduce

  1. File -> New Project -> MAUI Application
  2. Open error list
  3. Build, or just wait, occasionally you'll see this error:

MSB4044: The "GenerateRtxt" task was not given a value for the required parameter "JavaPlatformJarPath"

Did you find any workaround?

Rebuilding or reopening the project sometimes works

Relevant log output

No response

dellis1972 commented 2 weeks ago

@MSLukeWest do you have the binlog file which contains the error?

dotnet-policy-service[bot] commented 2 weeks ago

Hi @MSLukeWest. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

MSLukeWest commented 2 weeks ago

MauiApp7_Debug_AnyCPU_net9.0-android_DesignTimeBuild_2024-09-04T13_54_37.3636355-07_00.binlog.txt

@dellis1972 - I've attached the binlog. I had to rename it to a .txt file because .binlog can't be attached.

jonathanpeppers commented 2 weeks ago

A guess to what's happening is:

@MSLukeWest can you confirm, you don't have this installed?

image

MSLukeWest commented 2 weeks ago

A guess to what's happening is:

  • API 35 is not installed
  • <GetJavaPlatformJar/> does not appear to log errors or abort the build during a $(DesignTimeBuild); it can't find android.jar for API 35
  • <GenerateRtxt/> has [Required] public string JavaPlatformJarPath, and so we get an error

@MSLukeWest can you confirm, you don't have this installed?

image

@jonathanpeppers - I checked, and I do have this installed now. However, I can tell by the timestamps of the folders in "Program Files (x86)\Android\android-sdk\platforms\android-35" that it wasn't installed until 1 minute after I got this error.

jonathanpeppers commented 2 weeks ago

I was able to reproduce in an integration test.

And we can fix the error message above:

But it still fails later during <Csc/> with:

UnnamedProject\MainActivity.cs(15,29): error CS0117: 'Resource' does not contain a definition for 'Layout'
UnnamedProject\MainActivity.cs(17,48): error CS0117: 'Resource' does not contain a definition for 'Id'

It wasn't able to generate Resource.designer.cs without the android.jar platform jar, and so the build would still fail.