问题描述
我正在尝试将Proguard与Xamarin一起使用.因此,我在项目选项中将其启用(选中了Enable ProGuard
),然后在属性中创建了文件proguard.cfg
(作为新的文本文件,对吗?)并检查BuildAction-> ProguardConfiguration
I'm trying to use proguard with Xamarin.So I enabled it in project options (checked Enable ProGuard
), and I created a file proguard.cfg
in Properties, (as new Text file, is it right?)and checked the BuildAction -> ProguardConfiguration
proguard文件仅包含-keep配置,并带有注释.无论我留下还是删除评论,我总是在第1行出现解析错误:
The proguard file contains only a -keep configuration, with a comment. Whether I leave or remove the comment, I always get a parse error on line 1 :
# test comment
-keep class !android.support.v7.view.menu.**, !android.support.design.internal.NavigationMenu, !android.support.design.internal.NavigationMenuPresenter, !android.support.design.internal.NavigationSubMenu, android.support.** {*;}
我收到Unknown option '' in line 1
错误.
有什么主意吗?
推荐答案
我在文档的这一部分中添加了一段时间,提到您需要删除BOM(字节顺序标记):
I added this section of the docs awhile back to mention that you need to remove the BOM(Byte order mark):
注意::如果收到类似以下的错误,则说明配置文件包含ProGuard工具无法处理的字节顺序标记(BOM):
Note: If you get an error like the following, then your configuration file contains a byte order mark (BOM), which the ProGuard tool cannot handle:
Unknown option '-keep' in line 1 of file 'proguard.cfg'
为避免此问题,请从文本编辑器中保存您的自定义配置文件,该文件允许您省略BOM.例如,如果要从Notepad ++保存,则可以使用编码>在没有BOM的UTF-8中编码"选项来保存没有BOM的ProGuard配置文件.
To prevent this problem, save your custom configuration file from a text editor that allows you to omit the BOM. For example, if you are saving from Notepad++, you can use the Encoding > Encode in UTF-8 Without BOM option to save your ProGuard configuration file without BOM.
总的来说,您可以使用任何想要删除BOM的方法. Notepad ++使其非常简单.在此处添加完整的解决方案,以帮助其他人获得可见性.
By all means you can use whatever method you'd like to remove the BOM. Notepad++ makes it pretty simple. Adding the full solution here to help others for visibility.
正确的链接可以在这里找到:
The proper link can be found here:
https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/#File_Issues
这篇关于Xamarin proguard.ParseException:文件'Properties/proguard.cfg'的第1行中的未知选项''的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!