Skip to content

Commit 251663a

Browse files
[NativeAOT] Pass generated ACW keep rules to R8 on trimmable path
The trimmable NativeAOT path generates its ProGuard/R8 ACW keep rules from the ILC DGML into proguard_project_references.cfg (_ProguardProjectConfiguration) via GenerateNativeAotProguardConfiguration, and deliberately leaves R8's proguard_project_primary.cfg empty so that references.cfg is the sole source of ACW keeps. However _CalculateProguardConfigurationFiles excluded _ProguardProjectConfiguration for NativeAOT+trimmable, so R8 received no ACW keep rules and tree-shook every JCW/ACW (e.g. UncaughtExceptionMarshaler) out of classes.dex. The app then crashed at startup in JavaInteropRuntime.init with: java.lang.ClassNotFoundException: scrc64...UncaughtExceptionMarshaler Drop the trimmable exclusion so the generated keep rules reach R8. Verified on an arm64 emulator with CheckJNI enabled: the HelloWorld NativeAOT (trimmable) sample now retains the ACW JCWs in classes.dex and launches to MainActivity without crashing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 31c92ce commit 251663a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ because xbuild doesn't support framework reference assemblies.
20022002
<ItemGroup Condition=" '$(ProguardConfigFiles)' == '' ">
20032003
<_ProguardConfiguration Include="$(MSBuildThisFileDirectory)proguard-android.txt" />
20042004
<_ProguardConfiguration Include="$(IntermediateOutputPath)proguard\proguard_xamarin.cfg" Condition=" '$(AndroidLinkTool)' != '' " />
2005-
<_ProguardConfiguration Include="$(_ProguardProjectConfiguration)" Condition=" '$(AndroidLinkTool)' != '' and ('$(_AndroidRuntime)' != 'NativeAOT' or '$(_AndroidTypeMapImplementation)' != 'trimmable') " />
2005+
<_ProguardConfiguration Include="$(_ProguardProjectConfiguration)" Condition=" '$(AndroidLinkTool)' != '' " />
20062006
<_ProguardConfiguration Include="$(IntermediateOutputPath)proguard\proguard_project_primary.cfg" Condition=" '$(AndroidLinkTool)' != '' " />
20072007
<!-- @(ProguardConfiguration) should be listed last -->
20082008
<_ProguardConfiguration Include="@(ProguardConfiguration)" />

0 commit comments

Comments
 (0)