Forum Xamarin.Android

App crashes after making build using Dotfuscator

Hi,

I am trying to Obfuscate Xamarin Android build that is a cross platform application using XF. For Obfuscation, i am using trial version of Dotfuscator.

I can see that code obfuscation is working. I decompiled the apk and checked dll files and inside dll, obfuscated code was there.

But when i push that apk in mobile, it's got crashed. In error, i can clearly see that few methods are missing from view models.

When i make build without Dotfuscator, it's working fine. But after making build with Dotfuscator, it's crashes. I made build in release/debug mode and tried all the Linker options with Dotfuscator, but no luck.

Please help me to understand where exactly the issue is.

--
Devesh

Answers

  • DeveshMishraDeveshMishra USMember ✭✭

    I got the issue. It's mentioned here at

    https://www.preemptive.com/dotfuscator/pro/userguide/en/protection_exclusions.html#renaming

    But i am not very clear that why Renaming exclusion is required.

  • masoudshahrabimasoudshahrabi USMember ✭✭

    DeveshMishra is right. Most of the times it needs to exclude some classes. For me it was custom views that I had inherited and used them in axml files. They get renamed in the project and everywhere they are referenced except inside axml (or xml) files. You have to exclude them to prevent possible crashes. Another possibility is model classes that work with apis and web services. you need to exclude them as well. For example when you deserialize json content from server, all of the attributes has to be the same name as they are. For renaming exclusions you can use .net attributes in the code too. for example you can put [Obfuscation(ApplyToMembers:=True, Exclude:=True)] above of the classes you don't want to rename and all of their members. It is in the System.Reflection namespace. Since dotfuscator doesn't work in debug mode and you can't track where crash happens, logging Device is very useful too.

  • RezaMortazaviRezaMortazavi AZMember

    I remember I had the same situation. Adding debug capability to release mode, I found out Dotfuscator does not support Clicked event for ToolbarItem on Menu defined in Xaml file. I added x:Name to each ToolbarItem and moved those event declarations to page constructor and it worked currectly.

Sign In or Register to comment.