Xamarin proguard.ParseException: 文件“Properties/proguard.cfg"的第 1 行中的未知选项“" [英] Xamarin proguard.ParseException: Unknown option '' in line 1 of file 'Properties/proguard.cfg'

查看:37
本文介绍了Xamarin proguard.ParseException: 文件“Properties/proguard.cfg"的第 1 行中的未知选项“"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 proguard 与 Xamarin 一起使用.所以我在项目选项中启用了它(选中 Enable ProGuard),并在 Properties 中创建了一个文件 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 错误.

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:错误:工具退出,代码:1.输出:proguard.ParseException:文件Properties/proguard.cfg"的第 1 行中的未知选项""
包含在第 10 个参数中proguard.ConfigurationParser.parse(ConfigurationParser.java:191) 在proguard.ProGuard.main(ProGuard.java:484) (WheezMe.Droid)

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Tool exited with code: 1. Output: proguard.ParseException: Unknown option '' in line 1 of file 'Properties/proguard.cfg'
included from argument number 10 at proguard.ConfigurationParser.parse(ConfigurationParser.java:191) at proguard.ProGuard.main(ProGuard.java:484) (WheezMe.Droid)

有什么想法吗?

推荐答案

我在一段时间后添加了这部分文档,提到您需要删除 BOM(字节顺序标记):

I added this section of the docs awhile back to mention that you need to remove the BOM(Byte order mark):

注意:如果您收到类似以下的错误,则您的配置文件包含一个字节顺序标记 (BOM),ProGuard 工具无法处理:

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:

文件 'proguard.cfg' 的第 1 行中的未知选项 '-keep'

为防止出现此问题,请从允许您省略 BOM 的文本编辑器中保存您的自定义配置文件.例如,如果您从 Notepad++ 保存,您可以使用编码 > 以 UTF-8 编码无 BOM 选项来保存没有 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.

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/#ProGuard

无论如何,您可以使用任何您想要删除 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 行中的未知选项“"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆