marcu
marcu

Reputation: 233

Error while trying obfuscate Xamarin.android dll with ConfuserEx

I try to obfuscate Xamarin.Android dlls using ConfuserEx, but i get only error:

[ERROR] Failed to resolve dependency of 'app.dll'.
Exception: dnlib.DotNet.AssemblyResolveException: Could not resolve assembly: Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   w dnlib.DotNet.Extensions.ResolveThrow(IAssemblyResolver self, IAssembly assembly, ModuleDef sourceModule) w E:\Source\Public\Confuser2\dnlib\src\DotNet\IAssemblyResolver.cs:wiersz 113
   w Confuser.Core.ConfuserEngine.Inspection(ConfuserContext context) w e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:wiersz 264
Failed at 20:23, 0:01 elapsed.

My confuserEx project file:

<project outputDir="C:\Users\Admin\Desktop\android\app\Confused" baseDir="C:\Users\Admin\Desktop\android\app" xmlns="http://confuser.codeplex.com">
  <packer id="compressor" />
  <module path="obj\Debug\app.dll">
    <rule pattern="true" preset="normal">
      <protection id="rename" />
      <protection id="anti ildasm" />
      <protection id="anti tamper" />
      <protection id="constants" />
      <protection id="ctrl flow" />
    </rule>
  </module>
  <probePath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v6.0</probePath>
  <probePath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0</probePath>
</project>

How can i add dependency for project? What do i need add to project?

Thanks in advance

Upvotes: 4

Views: 1561

Answers (1)

Eugenio De Hoyos
Eugenio De Hoyos

Reputation: 1775

You need to specify the correct path that contains Xamarin.Android.Support.v4.dll, since it is not found within the Microsoft\Framework\MonoAndroid\vX.Y paths that you have already specified via the probePath elements.

Since Xamarin.Android.Support.v4 is added as a NuGet package, you'll either need to specify the correct path within your "packages" directory, which may look something like the following

<probePath>packages/Xamarin.Android.Support.v4.23.4.0.1/lib/MonoAndroid403/</probePath>

or if your IDE is behaving like mine, the Xamarin.Android.Support.v4 will be copied during build time into the obj/Debug path, in which case you could simply specify this relative path as follows:

<probePath>obj/Debug</probePath>

I'm not sure which is the "preferred pattern" to use, but either one of these approaches should address your issue.

Upvotes: 1

Related Questions