Error archiving an obfuscated app

nnovalbos 371 Reputation points
2021-09-24T22:21:17.367+00:00

I am trying to obfuscate the android apk from visual, with the obfuscator library, following the following manual: https://docs.obfuscar.com/tutorials/xamarin.html

I have added the following post compilation action in my android csproj file:

<Target Name = "AfterBuild" Condition = "'$ (Configuration)' == 'Release'">
    <Exec WorkingDirectory = "$ (MonoAndroidIntermediateAssetsDir)" Command = "'$ (Obfuscate)' $ (ProjectDir) obfuscar.xml" />
    <Copy SourceFiles = "$ (TargetDir) name.Android.dll" DestinationFolder = "$ (MonoAndroidIntermediateAssetsDir)" />
    <Copy SourceFiles = "$ (TargetDir) name.Core.dll" DestinationFolder = "$ (MonoAndroidIntermediateAssetsDir)" />
 </Target>

When I compile in release it seems to work, but when I try to archive the app it gives me the following error:

Error MSB3073: The command "mono Obfuscar.Console.exe '/obfuscar.xml" exited with code 1. (MSB3073)

my obfuscar.xml file is:

<Obfuscator>
    <Var name="RenameProperties" value="true" />
    <Var name="RenameEvents" value="true" />
    <Var name="RenameFields" value="true" />
    <Var name="KeepPublicApi" value="true" />
    <Var name="HidePrivateApi" value="true" />
    <Var name="HideStrings" value="true" />
    <Var name="UseUnicodeNames" value="true" />
    <Var name="OptimizeMethods" value="true" />
    <Var name="InPath" value="../name.Android/bin/Release" />
    <Var name="OutPath" value="$(InPath)/Obfuscator_Output" />
    <Module file="name.Android.dll" />
    <Module file="name.Core.dll" />
</Obfuscator>

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,272 questions
{count} votes