3

I have a task of obfuscating my Xamarin Android project (let call it AndrProj) together with libraries it references: two PCL (let's call them PCL1 and PCL2) and Android library (AndrLib). PCL2 and AndrLib also have references to PCL1.

I was inspired by this article and decided to try Crypto Obfuscator For .Net v2015 demo version for my purposes.

I used its 'Visual Studio Project Integration Wizard'. PCL1 was set as 'First project' and AndrProj as 'Last project'. Only default settings were used for the beginning. Now when I build my project everything is perfect. Dll's in \bin\Release folder are obfuscated.

I would be completely happy if I could actually create an .apk file and try it on the Android device. But when I select Build -> Archive for Publishing in Xamarin Studio, after some time I see 'Build FAILED' and

Error occurred while obfuscation: - The assembly 'AndrLib' is already obfuscated with Crypto Obfuscator. If you have run the Visual Studio Project Integration Wizard on your Visual Studio projects, you cannot obfuscate from the Crypto Obfuscator UI unless you first disable automatic obfuscation for this project from Crypto Obfuscator's 'Project' menu --> 'Enable/Disable Visual Studio Integration' and Rebuild your solution in Visual Studio to produce unobfuscated assemblies.

I also tried 'Export Android Package (.apk)' from Visual Studio 2013, but it gives less output and still does not create .apk.

I believe it complains only about AndrLib because it goes first alphabetically among PCL1, PCL2 and AndrLib. And more global problem is that creating .apk forces all assemblies to be obfuscated one more time. Is there any way to skip this second time obfuscation? Or to ignore this kind of problem?

4

2 回答 2

0

好吧,解决方案非常简单:我必须直接将 MSBuild.exe 与目标 SignAndroidPackage 一起使用,而不是从 IDE 创建 .apk。


这是来自技术支持的关于所描述问题的电子邮件(可能对某人有用):

如果您的解决方案在执行 MSBuild 集成后无法构建,请尝试以下操作:

更改生成输出日志详细程度如下:Visual Studio 工具菜单 --> 选项 --> 项目和解决方案 --> 生成和运行 --> MSBuild 项目生成输出详细程度,将其设置为详细。

现在检查 Visual Studio 输出窗口以获取有关错误原因的任何提示或更多信息。

将 MSBuild 使用的线程数更改为 1,如下所示:Visual Studio 工具菜单 --> 选项 --> 项目和解决方案 --> 构建和运行 --> 最大并行线程数:将其设置为 1。

如果您在运行 (CTRL+F5) 或调试 (F5) 解决方案时收到类似于“程序集 'XYZ' 已使用 Crypto Obfuscator 进行混淆...”的错误消息,请尝试执行清理(Visual Studio 构建菜单--> 清理菜单项),然后执行运行 (CTRL+F5) 或调试 (F5)。

如果您多次运行向导,每次选择不同的“第一个”项目,也会发生构建失败。此问题通常通过构建日志/输出中的“找不到文件”错误出现。要解决此问题,请从干净的非集成 .csproj/.vbproj 文件开始(向导会在修改项目文件之前将原始非集成项目文件复制到 .backup_%timestamp% 扩展名;或者您可以打开 .csproj/ .vbproj 文件并删除向导添加的 XML,可以在文件末尾找到)。然后再次运行向导,指定正确的第一个和最后一个项目。

于 2015-05-19T14:50:05.370 回答
0

我在归档时遇到问题,在我将 Visual Studio 2017 Professional 从 15.9.9 降级到 15.7.6 后问题就消失了。

于 2019-03-22T19:33:38.267 回答