2010-10-01 32 views
7

Google đang gợi ý rằng các nhà phát triển có thể muốn xáo trộn mã byte:Làm thế nào để tắt tất cả các tính năng của Android ProGuard ngoại trừ sự xáo trộn?

http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html

Tôi đi theo hướng dẫn của Google để có được một ứng dụng Android obfuscated rằng, ở cái nhìn đầu tiên, dường như làm việc. Nhưng có một số lỗi lạ được giới thiệu mà không có trong ứng dụng không bị xáo trộn. Tôi giữ tắt tùy chọn ProGuard để có được cấu hình này:

-dontoptimize -dontshrink -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose

Tuy nhiên những loại vi trùng đó. Có bất cứ điều gì khác tôi có thể tắt để có được chỉ obfuscation tinh khiết? Obfuscation sẽ là tốt đẹp, nhưng tôi sẵn sàng tắt các tính năng khác của ProGuard.

+0

Xin chào! Bạn đã tìm thấy giải pháp cho câu hỏi của mình chưa? Tôi cũng phải đối mặt với cùng một vấn đề. https://stackoverflow.com/questions/47716524/proguard-android-execution-failed-for-task-presentationtransformclasseswith – yozhik

Trả lời

7

Đây là những gì tôi sử dụng:

-libraryjars ${android.jar} 
-injars  temp.jar 
-outjars proguard.jar 

#-printseeds: Prints the un-obfuscated filenames 
-printseeds 
-printmapping mapping-used-to-retrace-exceptions.txt 
-verbose 

#-dontusemixedcaseclassnames: Necessary when building on windows where x.class and X.class is the same file 
-dontusemixedcaseclassnames 

#-repackageclasses: Adds further obfuscation, Counter-indication: classes that look for resource files in their package directories will no longer work properly if they are moved elsewhere. When in doubt, just leave the packaging untouched by not using this option. 
-repackageclasses '' 

#-dontskipnonpubliclibraryclasses: Counter-indication: you probably shouldn't use this option when processing code that is to be used as a library, since classes and class members that weren't designed to be public in the API may become public. 
-dontskipnonpubliclibraryclasses 

-keep public class * extends android.app.Activity 
-keep public class * extends android.app.Service 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider 
-keep class * extends android.view.View { 
    public <init>(android.content.Context); 
    public <init>(android.content.Context, android.util.AttributeSet); 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
    public void set*(...); 
} 
-keep class * extends android.preference.Preference { 
    public <init>(android.content.Context); 
    public <init>(android.content.Context, android.util.AttributeSet); 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
    public void set*(...); 
}  
# LVL License binder class 
-keep class com.android.vending.licensing.ILicensingService  
# This is necessary for LVL among others. According to proguard doc java accesses enum fields by introspection. 
-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 
#Optimization settings 
-dontoptimize 

Nó hoang mang nhưng giữ công chúng phương pháp nào và tên lớp của các lớp học cần thiết cho Android. Như bạn đã yêu cầu, nó không tối ưu hóa - tối ưu hóa có nhiều khả năng phá vỡ chương trình của bạn hơn do các phương thức và phương thức khởi tạo đã bị loại bỏ.

Nếu bạn muốn thử bao gồm tối ưu hóa ở đây là những gì tôi làm (nhớ để loại bỏ các tùy chọn -dontoptimize trên)

#Optimization settings  
# Keep (ie. don't remove) all public constructors of all public classes, but still obfuscate+optimize their content. This is necessary because optimization removes constructors which I use through reflection. 
-keepclassmembers class * { 
    <init>(...); 
} 

-optimizationpasses 7 
-allowaccessmodification 
# The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. 
-optimizations !code/simplification/arithmetic 

tôi sử dụng Proguard 4.5, nhưng các phiên bản khác có thể làm việc chỉ là tốt.

Các vấn đề liên quan