2012-06-22 7 views
6

Sto cercando di offuscare la mia applicazione Android utilizzando proguard e ant (eclipse + proguard non funziona mai, non riesce sempre con error 1). Ma sto ricevendo l'avviso class file ... unexpectedly contains class ... che è il posto e la compilazione fallisce. Ho anche provato con l'opzione -ignorewarnings in proguard. La compilazione supera, ma ottengo un pacchetto inutilizzabile.offuscamento ActionBarSherlock con Proguard

Ecco l'output ant:

-post-compile: 

optimize: 
    [jar] Building jar: /home/binoy/git/Vibhinna/proguard/unoptimized.jar 
    [java] ProGuard, version 4.8 
    [java] Reading input... 
    [java] Warning: class [classes/com/actionbarsherlock/R$array.class] unexpectedly contains class [com.actionbarsherlock.R$array] 
    [java] Warning: class [classes/com/actionbarsherlock/R$attr.class] unexpectedly contains class [com.actionbarsherlock.R$attr] 
    [java] Warning: class [classes/com/actionbarsherlock/R$bool.class] unexpectedly contains class [com.actionbarsherlock.R$bool] 
    [java] Warning: class [classes/com/actionbarsherlock/R$color.class] unexpectedly contains class [com.actionbarsherlock.R$color] 
    .... 
    [java] Warning: class [classes/com/actionbarsherlock/R$xml.class] unexpectedly contains class [com.actionbarsherlock.R$xml] 
    [java] Warning: class [classes/com/actionbarsherlock/R.class] unexpectedly contains class [com.actionbarsherlock.R]. 
    [java] Warning: class [classes/com/vibhinna/binoy/DetailsDialogFragment$1.class] unexpectedly contains class [com.vibhinna.binoy.DetailsDialogFragment$1] 
    [java] Warning: class [classes/com/vibhinna/binoy/DetailsDialogFragment.class] unexpectedly contains class [com.vibhinna.binoy.DetailsDialogFragment] 
    [java] Warning: class [classes/com/vibhinna/binoy/HoloAlertDialogBuilder.class] unexpectedly contains class [com.vibhinna.binoy.HoloAlertDialogBuilder] 
    [java] Warning: class [classes/com/vibhinna/binoy/MiscMethods.class] unexpectedly contains class [com.vibhinna.binoy.MiscMethods] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$1$1.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$1$1] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$1$2.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$1$2] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$1.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$1] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$10.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$10] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$11.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$11] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$2.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$2] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$3.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$3] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$4.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$4] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$5.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$5] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$6.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$6] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$7.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$7] 
    [java] Warning: class [classes/com/vibhinna/binoy/NewDialogFragment$8.class] unexpectedly contains class [com.vibhinna.binoy.NewDialogFragment$8] 
    .... 
    [java] Warning: class [classes/com/vibhinna/binoy/Preferences.class] unexpectedly contains class [com.vibhinna.binoy.Preferences] 
    [java] Warning: class [classes/com/vibhinna/binoy/ProcessManager.class] unexpectedly contains class [com.vibhinna.binoy.ProcessManager] 
    [java] Warning: there were 89 classes in incorrectly named files. 
    [java]   You should make sure all file names correspond to their class names. 
    [java]   The directory hierarchies must correspond to the package hierarchies. 
    [java]   If you don't mind the mentioned classes not being written out, 
    [java]   you could try your luck using the '-ignorewarnings' option. 
    [java] java.io.IOException: Please correct the above warnings first. 
    [java]  at proguard.InputReader.execute(InputReader.java:133) 
    [java]  at proguard.ProGuard.readInput(ProGuard.java:197) 
    [java]  at proguard.ProGuard.execute(ProGuard.java:79) 
    [java]  at proguard.ProGuard.main(ProGuard.java:493) 

Come posso risolvere questo problema?

+0

http://actionbarsherlock.com/faq.html (vedere la sezione sull'utilizzo di proguard) –

risposta

28

Assicurarsi che il file di configurazione Proguard ha la recommended exclusions per ActionBarSherlock:

-keep class android.support.v4.app.** { *; } 
-keep interface android.support.v4.app.** { *; } 
-keep class com.actionbarsherlock.** { *; } 
-keep interface com.actionbarsherlock.** { *; } 
-keepattributes *Annotation* 

provare anche aggiungendo

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

come suggerito here.

+0

Ancora nessuna modifica, 89 classi ancora in file con nome errato. –

+0

Prova anche ad aggiungere la classe '-keepclassmembers **. R $ * { statico pubblico ; } ' – Jeshurun

+0

http://pastebin.com/3sAhwrQA proguard.cfg. 89 ancora –