eclipse Proguard 解析异常错误。如何解决
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17041097/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Proguard Parse Exception Error. How to solve it
提问by Jimit Patel
I am trying to export my application using Proguard 4.9 for the first time. But while exporting I am getting weird error in Console. Here it is -
我第一次尝试使用 Proguard 4.9 导出我的应用程序。但是在导出时,我在控制台中遇到了奇怪的错误。这里是 -
[2013-06-11 14:59:42 - Project1] Proguard returned with error code 1. See console
[2013-06-11 14:59:42 - Project1] proguard.ParseException: Expecting type and name instead of just '***' before '(' in line 193 of file 'D:\Project Works\Android\Project1\bin\proguard.txt',
[2013-06-11 14:59:42 - Project1] included from argument number 4
[2013-06-11 14:59:42 - Project1] at proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:889)
[2013-06-11 14:59:42 - Project1] at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:729)
[2013-06-11 14:59:42 - Project1] at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:516)
[2013-06-11 14:59:42 - Project1] at proguard.ConfigurationParser.parse(ConfigurationParser.java:165)
[2013-06-11 14:59:42 - Project1] at proguard.ProGuard.main(ProGuard.java:476)
Here is the bin\proguard.txt file of line 192 & 193, where the error is coming
这是第192和193行的bin\proguard.txt文件,错误来了
# onClick res/layout/tmenu.xml #generated:77
-keepclassmembers class * { *** (...); }
In project.properties I am using
在 project.properties 我使用
target=android-7
proguard.config=proguard.cfg
And I am Android SDK and eclipse's plugins are updated to latest. Any idea how to fix it???
而且我是Android SDK,eclipse的插件都更新到最新了。知道如何修复它吗???
EDITHere is the proguard.cfg in my project
编辑这是我项目中的 proguard.cfg
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
采纳答案by Pankaj Kumar
Error is at
错误在
-keepclassmembers class * { *** (...); }
Replace with
用。。。来代替
-keepclassmembers class mypackage.** { *; }
And if you set this config for setters/ getters, you need to modify as
如果您为 setter/getter 设置此配置,则需要修改为
-keep class mybeans.** {
void set*(***);
void set*(int, ***);
boolean is*();
boolean is*(int);
*** get*();
*** get*(int);
}
Where : The '***
' wildcard matches any type (primitive or non-primitive, array or non-array). The methods with the 'int' arguments matches properties that are lists.
其中:“ ***
”通配符匹配任何类型(原始或非原始、数组或非数组)。带有“int”参数的方法匹配列表属性。
回答by Jevgenij Evll
In my case I was receiving this error because of an empty onClick attribute in a layout file. So I removed onClick=""
, and the error was gone
就我而言,我收到此错误是因为布局文件中的 onClick 属性为空。所以我删除了onClick=""
,错误消失了
回答by Alvi
In my case the error was due to an empty onClick attribute on a button in a layout file. So I removed onClick=""
, and the error was gone.
TO find the the correct layout file that causing this error go to the corresponding file and find which layout file is causing this problem.
The file is rightly on the or one line above the line indicated in the error message like
在我的情况下,错误是由于布局文件中按钮上的空 onClick 属性造成的。所以我删除了onClick=""
,错误消失了。
要找到导致此错误的正确布局文件,请转到相应文件并查找导致此问题的布局文件。该文件正确地位于错误消息中指示的行上方的一行或一行上,例如
In line 193 of file 'D:\Project Works\Android\Project1\bin\proguard.txt' or in line 114 of file 'C:..app\build\intermediates\proguard-rules\debug\aapt_rules.txt' .
Go through the layout file and find the onClick=""
in any view. Remove it.
Hopefully this will work.
浏览布局文件并onClick=""
在任何视图中找到。去掉它。
希望这会奏效。