How to use .Net Reactor obfuscated dll of Xamarin Android APK

后端 未结 3 942
予麋鹿
予麋鹿 2021-02-10 05:55

I am new to Xamarin Android. I have created an App using Visual Studio 2015 Community Edition. I have set the Solution Configuration to Release.

For obfuscation I used .

3条回答
  •  臣服心动
    2021-02-10 06:20

    I got my Xamarin Android project in Xamarin Studio obfuscating fine with .NET Reactor by hooking into MSBuild. Add this markup to the bottom of your csproj file:

      
        
      
    
    

    To note, when I upgraded to Xamarin in Visual Studio 2015 this does not work anymore. Gave me a "error MSB4018: The "LinkAssemblies" task failed unexpectedly."

    **edit I got past the 'LinkAssemblies' task error by setting PostBuild to true and hooking to the 'PostBuildEvent' event instead as Ajit pointed out.

    However, the obfuscated DLL is not getting added to the apk file. I tested this by unzipping the .apk file (just change the file extension to .zip or .rar) and decompiling the DLL file inside. It was not obfuscated.

    I looked in the bin/Release and the obj/Release folders, and the DLL in there is obfuscated. But for some reason, the DLL in the apk is not the obfuscated DLL.

    Perhaps the PostBuildEvent is too late in the process of creating the apk file?

    Here is my current setup:

    Set the PostBuild to true:

      
        ...
        true
      
    

    and then hook to the 'PostBuildEvent' event instead 'AfterCompile'

      
        
      
    
    

    ** update I created a simple blank Android project in VS 2015 to test if the problem may be caused by the complexity of my project (use of 3rd party controls, common utility library as a 2nd project in solution, etc). The 'LinkAssemblies' error still occurs so it's probably my environment/setup.

    I have a GitHub account but haven't downloaded the app, so I couldn't upload the entire project folder structure, so I just zipped up the whole solution and uploaded that. It's available here:

    https://github.com/nbcruz/TestObfuscate/blob/master/TestObfuscate.zip

    I had to delete the contents of the obj/Debug folder as it had 78MB of files to make the zip file under 25MB for GitHub to allow.

    The .NET Reactor project is inside the bin\Release\ folder. I manually run it and create the obfuscated DLL which is inside the bin\Release\TestObfuscate_Secure folder. The obfuscate.bat file is also inside the bin\Release\ folder and it basically just copies the DLL inside the bin\Release\TestObfuscate_Secure folder into the bin\Release\ folder. This blank simple solution still throws the 'LinkAssemblies' error.

提交回复
热议问题