Proguard失败了25.1.6版本的Android工具

时间:2016-05-13 14:33:44

标签: android proguard android-sdk-tools

我今天下载了Android工具的25.1.6版本,我注意到proguard因此错误而失败:

Error:Execution failed for task ':app:transformClassesWithNewClassShrinkerForDebug'.
> /usr/local/opt/android-sdk/tools/proguard/proguard-android.txt line 43:15 extraneous input '[]' expecting ')'

我确定我在proguard-android.txt文件中没有更改任何内容。第43行为我读取如下:

void set*(%[]);

我注意到这里的文件......

https://android.googlesource.com/platform/sdk/+/android-6.0.1_r43/files/proguard-android.txt

...与我机器上的不同?该文件是我应该拥有的文件的最新版本吗?

4 个答案:

答案 0 :(得分:4)

了解几个选项:

帮助我的是将相应的proguard-android.txt文件替换为this页面中的文件

以防万一页面在此处保存其内容:

# 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);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
    public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**

答案 1 :(得分:3)

嗯,看起来我的Android SDK本地副本中的tools/proguard文件夹未被Android SDK Manager更新。我刚从这里重新下载了Android SDK ......

http://developer.android.com/sdk/index.html

...并在我的Android SDK本地副本中的tools/proguard上替换了该分发中的tools/proguard文件夹,并且错误消失了。

如果tools/proguard文件夹是通过Android SDK Manager更新的,那就太棒了。

答案 2 :(得分:2)

似乎发生在我们中的一些人身上。我只下载了这个答案中附带的文件夹,并将其复制到android-sdk / tools文件夹中,覆盖了那里的内容,现在它没有问题。

https://code.google.com/p/android/issues/detail?id=210012

答案 3 :(得分:0)

在调试模式下,我将 minifyEnabled 设置为 false