4

我尝试在 MAC 上使用带有 eclipse ADT v21.1.0-569685 的 Proguard 优化我的 Android 应用程序代码。我使用项目-> Android 工具-> 导出已签名的应用程序包选项来使用我的私人证书进行签名,签名完成后出现以下错误,

项目属性

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../google-play-services_lib

proguard-project.txt

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

控制台日志:

[2013-04-12 10:41:53 - MyApp] Proguard returned with error code 1. See console
[2013-04-12 10:41:53 - MyApp] proguard.ParseException: Expecting class member name before '@' in line 82 of file '/Users/MyOrg/Android_workspace/MyApp/bin/proguard.txt',
[2013-04-12 10:41:53 - MyApp]   included from argument number 6
[2013-04-12 10:41:53 - MyApp]   at proguard.ConfigurationParser.readNextWord(ConfigurationParser.java:1133)
[2013-04-12 10:41:53 - MyApp]   at proguard.ConfigurationParser.readNextWord(ConfigurationParser.java:1117)
[2013-04-12 10:41:53 - MyApp]   at proguard.ConfigurationParser.parseMemberSpecificationArguments(ConfigurationParser.java:845)
[2013-04-12 10:41:53 - MyApp]   at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:697)
[2013-04-12 10:41:53 - MyApp]   at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:490)
[2013-04-12 10:41:53 - MyApp]   at proguard.ConfigurationParser.parse(ConfigurationParser.java:139)
[2013-04-12 10:41:53 - MyApp]   at proguard.ProGuard.main(ProGuard.java:484)
  1. 如何解决上述问题?
  2. 在我阅读的 prouard.project 文件中

如果您的项目使用带有 JS 的 WebView,请取消注释以下内容并将完全限定的类名指定给 JavaScript 接口类:

我在 WebAppInterface.java 类的两个活动中使用了 webview。如何执行上述语句?

4

1 回答 1

6

在布局文件的android:onClick属性中引用资源名称如“ @string/on_click_handler_name ”是可以的。但是,proguard 无法解析这些引用。

查看http://android.okhelp.cz/proguard-parseexception-expecting-class-member-name-before/了解更多详情。

在您的string.xml中找到@string/tha_lf_et_todate_onclick的相应值并更新:

android:onClick="@string/tha_lf_et_todate_onclick" 

android:onClick="onClickXXX" 

在您的布局文件中。对于第二个问题,取消注释那段代码,并将“fqcn.of.javascript.interface.for.webview”替换为类的完全限定名称。

于 2013-08-13T01:38:02.223 回答