Skip to content

Xamarin.Android Obfuscation with mkaring ConfuserEx

Giuseppe Novielli edited this page Aug 8, 2020 · 2 revisions

Visual Studio for Mac - Xamarin.Android Obfuscation ConfuserEx 1.4.1 https://github.com/mkaring/ConfuserEx

Last Update 08/08/2020

Incomplete Obfuscation! Please Help Me!

Feature and Note

  • Obfuscate ONLY .NET STANDARD project
  • Not embedded into .apk files when publish Xamarin.Android project
  • I don't known when is good, launch obfuscation process, i set into Target (see into Setup section) 'AfterBuild', but i'm not sure-
  • if try to obfuscate Xamarin.Android .dll it said that can't find Xamrin.Froms.Xaml .dll
  • I have analyzed .dll, with https://github.com/icsharpcode/AvaloniaILSpy for Mac after obfuscation and it is obfuscated!
  • I'm not expert of MS Build and Xamarin.Android compile's steps!

Setup

  • Download last version of ConfuserEx https://github.com/mkaring/ConfuserEx/releases/download/v1.4.1/ConfuserEx.zip

  • Unpack into main project folder

  • Add .crproj into previous folder, see example PrismFullNavigation/confuserex_1.4.1/project.crproj (please open file and edit path file)

  • Add a .sh (script file), into main project folder, that launch ConfuserEx and run some other operations, see example PrismFullNavigation/obfuscator_2.sh (please open file and edit path file)

  • Into PrismFullNavigation.Android.csproj add this follow lines

<Target Name="Obfuscate" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'"> <Exec Command="$bash /Users/hrcoffee2/XF-Prism-Full-Navigation-Example-master/PrismFullNavigation/obfuscator_2.sh" WorkingDirectory="$(SolutionDir)" /> </Target>

  • Into PrismFullNavigation.csproj add follow lines. That resolve ConfuserEx .dll that must find.

<PropertyGroup> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> </PropertyGroup>

Usage

  • Set Xamarin.Android into Release Mode

  • Compile Project

  • At the end a new folder PrismFullNavigation/PrismFullNavigation.Android/bin/obfuscate contain .dll .NET Standard obfuscate that files, are already copied into:

  • PrismFullNavigation/PrismFullNavigation.Android/bin/Release

  • PrismFullNavigation/PrismFullNavigation/bin/Release/netstandard2.0

  • PrismFullNavigation/PrismFullNavigation/obj/Release/netstandard2.0

Clone this wiki locally