Skip to content

Commit e43bd8b

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 dd75e13 commit e43bd8b

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
@@ -1990,7 +1990,7 @@ because xbuild doesn't support framework reference assemblies.
19901990
<ItemGroup Condition=" '$(ProguardConfigFiles)' == '' ">
19911991
<_ProguardConfiguration Include="$(MSBuildThisFileDirectory)proguard-android.txt" />
19921992
<_ProguardConfiguration Include="$(IntermediateOutputPath)proguard\proguard_xamarin.cfg" Condition=" '$(AndroidLinkTool)' != '' " />
1993-
<_ProguardConfiguration Include="$(_ProguardProjectConfiguration)" Condition=" '$(AndroidLinkTool)' != '' and ('$(_AndroidRuntime)' != 'NativeAOT' or '$(_AndroidTypeMapImplementation)' != 'trimmable') " />
1993+
<_ProguardConfiguration Include="$(_ProguardProjectConfiguration)" Condition=" '$(AndroidLinkTool)' != '' " />
19941994
<_ProguardConfiguration Include="$(IntermediateOutputPath)proguard\proguard_project_primary.cfg" Condition=" '$(AndroidLinkTool)' != '' " />
19951995
<!-- @(ProguardConfiguration) should be listed last -->
19961996
<_ProguardConfiguration Include="@(ProguardConfiguration)" />

0 commit comments

Comments
 (0)