2016-05-13 71 views
5

没有我今天下载了25.1.6版本Android的工具,我注意到,proguard的正在下降超过此错误:ProGuard和25.1.6版本Android的工具

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

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

回答

3

嗯,它看起来是tools/proguard文件夹在我的本地副本的Android SDK没有更新的Android SDK管理器。我刚刚下载了Android SDK重新从这里...

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

...在我的本地Android SDK中的副本和错误不见了取代在分布在tools/proguardtools/proguard文件夹。

如果通过Android SDK管理器更新tools/proguard文件夹,效果会很好。

2

似乎这是发生在我们一些人身上。我只下载了这个答案中的文件夹,并将其复制到android-sdk/tools文件夹中,覆盖了那里的内容,现在它可以正常工作。

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

+0

嗨@Eylen,请参阅我在此主题中的回答。我发现的根本问题是'tools/proguard'文件夹未作为Android SDK管理器窗口中Android工具更新的一部分进行更新。您可能最好从Android SDK的新下载中获取'tools/proguard'文件夹,而不是在答案中的链接,因为后者可能不会被更新,并且会随着时间而过时。 –

+1

是的,你可能是对的。但我希望在未来的更新文件夹将正确更新 – Eylen

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.** 
+0

哪里可以找到“对应的proguard-android.txt文件”? –

+0

我在'〜/ Android/Sdk/tools/proguard/proguard-android.txt'中发现了我的。如果这不适合你,请尝试'find/path/to/android/sdk | grep'proguard-android.txt'。 – sbeliakov

0

在调试模式下,我设置了minifyEnabled to false

+1

你会遇到这个问题,然后当你发布版本...除非你的'/tools/proguard'文件夹中的文件是最新的。 –