Open awattar opened 9 months ago
Can you share a sample project that shows this problem? Thanks!
@jonathanpeppers Will try to share something but first will check it on net8.
Was able to reproduce it on NET8. Will work on sample to share.
Will retest on latest workloads and let you know.
@jpobst @jonathanpeppers I've retested on everything being updated (dotnet, workloads, VSMac, VSWin, etc.) and it can be easily reproduced on VSMac, VSWin and CLI builds.
I've uploaded samples and mappings files in the private comment in this ticket https://developercommunity.visualstudio.com/t/Code-sample-for-https:githubcomxamar/10666925
@awattar sorry for the delay. I'm able to run XamarinForms\Examples\SampleAppSuite\SampleAppSuite.Droid.csproj
in Release
mode and make it to this screen:
Are there more specific steps to see the problem here? Can you share the steps in terms of dotnet build
commands?
A tester was also unsuccessful in reproducing the issue.
@jonathanpeppers tried to reach you on Discord - but no response to my DM.
You need to run into "incremental" mode. Please try this scenario:
dotnet build -t:Run -c Release -f net8.0-android34.0
while only one physical Android device is attached or add -p:AdbTarget="-s insert_SERIAL_here"
when more than one physical device is connected.App will deploy and run and will crash immediately with log entries suggesting proguard issue - also mapping.txt will have different size than normal.
Is VS Mac required to cause the problem here? VS Mac is retiring next month:
You need to run into "incremental" mode
The steps above are a fresh build. In what way is it incremental?
@jonathanpeppers No VSMac is not required but this is a 100% repro.
This is a "incremental" build in the way that if you add --no-incremental
to the above command it will work - see my initial description.
I can provide another scenario if you can't work on this one.
Proguard/R8 rules do not do anything in Debug
mode. So, do the above steps need to be done in Release
mode?
--no-incremental
is equivalent to -t:Rebuild
:
So, can your steps above be reduced to:
dotnet build XamarinForms\Examples\SampleAppSuite\SampleAppSuite.Droid.csproj -c Release -t:Run
dotnet build XamarinForms\Examples\SampleAppSuite\SampleAppSuite.Droid.csproj -c Release -t:Run
(a second time)@jonathanpeppers Yes Release
was specified in the previous post https://github.com/dotnet/android/issues/8523#issuecomment-2226534031 to make proguard/R8 work.
Regarding the steps you have provided I'm not quite sure - I believe it has something to do with separate initial Restore
- so it builds some cache or sth from referenced NuGets then it treats consecutive build
and -t:Run
incrementally so it does not fully recreate proguard mappings.
Please try scenario with VSMac if you can.
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VSMac 17.6.7 (build 417), VSWin 17.8.0, .NET 7.0.402
Description
When building MS.Android net7 Platfrom/Maui app with ProGuard/R8 enabled in release rules from dependent binding library containing library level ProGuard are not taken into account or malformed.
App crashes on runtime.
Related to #4449 and #5310.
Steps to Reproduce
Going straight to VS deploy (CLI
-t:Run
) for the removed bin/obj folders also doesn't work.It seems that restore + build causes creation of malformed mapping.txt (in bin framework/platform/architecture subfolder) file. FIle is significantly smaller than the working file +- 20%.
Did you find any workaround?
App must be explicitly rebuild (instead of build) or additional
--no-incremental
option must be added to CLIdotnet build
. It seems that some targets related to the ProGuard/R8 are not invoked fully or in the wrong moment for builds after project restore. Probably those builds are treated as incremental and due to some performance optimisations not all rules are taken into account.Relevant log output
No response