2016-05-13 75 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'文件夾中的文件是最新的。 –