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 525 forks source link

GenerateJavaStubs takes a long time when building incrementally for a maui project #8920

Open dellis1972 opened 4 months ago

dellis1972 commented 4 months ago

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

.NET 8.x

Description

I am seeing a 7 second task run time when building a Maui applicaiton incrementally.

 7214 ms  GenerateJavaStubs                          1 calls

Steps to Reproduce

  1. Create a new maui app (dotnet new maui)
  2. dotnet build -f net8.0-android
  3. change CounterBtn.Text = $"Clicked {count} time"; to CounterBtn.Text = $"Clicked {count} time(s)"; in MainPage.xml.cs
  4. dortnet build -f net8.0-android -bl

Did you find any workaround?

None

Relevant log output

No response

dellis1972 commented 4 months ago

android-inc.binlog.zip

jpobst commented 4 months ago

This seems to be related to the "per-RID assembly" and "marshal methods" changes.

We now do the following additional work we did not do previously:

The actual "Generate Java Stubs" task does not need to scan Mono.Android.dll, and only needs one architecture to create the JLO's from.

The additional work is needed by LLVM marshal methods, but we should investigate if we can avoid it when that feature is disabled, like in Debug mode.

For context, on my DevBox, the MAUI template default clean build (no devices attached) timing for GenerateJavaStubs is: