ProGuard给出了不明确的错误

时间:2013-12-06 13:15:50

标签: java android obfuscation proguard

我正在尝试导出应用程序,同时打开proguard并获得以下异常

[2013-12-06 18:03:21 - ProjectName] Proguard returned with error code 1. See console
[2013-12-06 18:03:21 - ProjectName] proguard.ParseException: Expecting jar or directory name before '-include' in argument number 3
[2013-12-06 18:03:21 - ProjectName] at proguard.ConfigurationParser.readNextWord(ConfigurationParser.java:1133)
[2013-12-06 18:03:21 - ProjectName] at proguard.ConfigurationParser.parseClassPathArgument(ConfigurationParser.java:249)
[2013-12-06 18:03:21 - ProjectName  at proguard.ConfigurationParser.parse(ConfigurationParser.java:130)
[2013-12-06 18:03:21 - ProjectName] at proguard.ProGuard.main(ProGuard.java:484)

通常行号表示错误的位置,但我无法理解此类问题的原因是什么

ProGuard配置如下:

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}
-keep class com.example.google.tv.leftnavbar.**
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}
-libraryjars 

2 个答案:

答案 0 :(得分:0)

-libraryjars接受参数class_path。有关详细信息,请参阅http://proguard.sourceforge.net/index.html#manual/usage.html。如果您没有其他要处理的罐子,可以删除此行。

答案 1 :(得分:0)

除了Tina Roh的更正之外,你应该检查传递给ProGuard的命令行参数 - 特别是参数#2似乎缺少文件名。

  • 如果您将ProGuard作为独立工具运行,则很容易检查。
  • 如果您通过其他构建工具运行ProGuard,则必须找出该工具正在传递的参数。例如,引用包含空格的文件名可能存在问题。如果有任何错误,升级到最新版本可能会有所帮助。