2012-08-30 25 views
19

Dưới đây là cấu hình Proguard của tôi (tôi sao chép nó từ thư mục công cụ android và thêm một số dòngKhông thể teo loạt với Proguard

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* 
-optimizationpasses 5 
-allowaccessmodification 
-dontpreverify 


# The remainder of this file is identical to the non-optimized version 
# of the Proguard configuration file (except that the other file has 
# flags to turn off optimization). 

-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-verbose 

-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); 
} 

-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$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.** 

###################### 
# added by me 
######################## 
# guava 
-keepclasseswithmembers class com.google.common.base.internal.Finalizer{ 
    <methods>; 
} 

-dontwarn sun.misc.Unsafe 
-dontwarn com.google.common.collect.MinMaxPriorityQueue 

# 
#Action Bar Sherlock 
-keep class android.support.v4.app.** { *; } 
-keep interface android.support.v4.app.** { *; } 
-keep class com.actionbarsherlock.** { *; } 
-keep interface com.actionbarsherlock.** { *; } 


#-dontobfuscate  
#-libraryjars libs/FlurryAgent.jar 

Tôi muốn sử dụng Flurry trong ứng dụng của tôi, nhưng khi tôi cố gắng để xáo trộn ứng dụng của tôi với FlurryAgen.jar các Proguard không nói một dosens lỗi như thế này:.

Warning: com.flurry.android.ay: can't find referenced class com.google.ads.AdListener 

Cũng Proguard thất bại khi tôi cố gắng không để xáo trộn các nguồn

Làm thế nào để sử dụng loạt với Proguard 012?Và làm thế nào để làm cho proguard không obfuscate nguồn của tôi?

CẬP NHẬT Ngoài ra tôi đã đề cập rằng FlurryAgent.jar dường như đã bị làm mờ - http://korniltsev.ru/p/jBU0f1c.png. Có thể chúng ta có thể bỏ qua việc thu hẹp toàn bộ cái bình?

Trả lời

46

Cuối cùng tôi cố gắng làm điều đó như thế này:

-keep class com.flurry.** { *; } 
-dontwarn com.flurry.** 
+0

bạn đã có thể xác minh rằng Flurry vẫn đang thu thập số liệu thống kê chính xác trong thực tế, với '-dontwarn com.flurry. **'? Tôi đang ở trong tình trạng tương tự đang cố gắng sử dụng Proguard trên một ứng dụng sử dụng Flurry, nhưng hơi thận trọng khi nói đến việc sử dụng 'dontwarn' vì tôi không thực sự hiểu chuyện gì đang diễn ra. –

+8

Theo dõi: chỉ để thêm một chút quyền hạn cho câu trả lời của bạn, tôi vừa tải xuống lại SDK Flurry Android và trong tệp * FlurryAds-READMEv3.0.5.pdf *, ở phần cuối, có một phần rất ngắn gọn lần đọc: * 7. Sử dụng ProGuard (Tùy chọn) Nếu bạn dự định chạy ProGuard trên APK của mình trước khi phát hành ứng dụng, bạn cần thêm thông tin sau vào tệp "proguard.cfg": -keep class com.flurry. ** {*; } -dontwarn com.flurry. ** * Vì vậy, tôi đoán tôi sẽ sử dụng phương pháp này, mặc dù bỏ qua nhiều cảnh báo này khiến tôi hơi khó chịu. –

5

Tôi không chắc chắn về cách Flurry tương tác cụ thể với AdListener, nhưng tên của lớp Google là những gì đang bị làm xáo trộn.

Thử thêm dòng -keep public class com.google.ads.AdListener vào tệp bảo vệ. Bạn có thể cần phải thêm một vài ngoại lệ của lớp nếu Flurry sử dụng các lớp com.google.ads khác, nhưng dòng đó sẽ giải quyết cảnh báo ngay lập tức của bạn.

CẬP NHẬT: Vấn đề là tên phương thức lớp công khai đang bị làm phiền cho các thư viện quảng cáo khác nhau. Vì vậy, bạn có thể cần phải bao gồm các thiết lập Proguard bổ sung bao gồm các phương pháp:

-keep public class com.google.ads.** { public protected *; } 
-keep public class com.inmobi.androidsdk.** { public protected *; } 
-keep public class com.millenialmedia.android.** { public protected *; } 
-keep public class com.mobclix.android.sdk.** { public protected *; } 
-keep public class com.jumptap.adtag.** { public protected *; } 

Sau khi làm việc với Flurry và Proguard bản thân mình, đừng hãy chắc chắn để kiểm tra các gói ứng dụng triệt để trước khi tải lên thị trường ứng dụng của bạn (s) lựa chọn.

+0

Cảm ơn bạn đã trả lời! Tôi có rất nhiều cảnh báo (http://korniltsev.ru/p/jBU05Go.png), do đó, theo ý kiến ​​của tôi bỏ qua chúng không phải là giải pháp. Ngoài ra tôi đã đề cập rằng FlurryAgent.jar dường như đã bị làm mờ - http://korniltsev.ru/p/jBU0f1c.png. Có thể chúng ta có thể bỏ qua việc thu hẹp toàn bộ cái bình? –

+0

Vâng, tôi đã sử dụng Flurry mà không có bất kỳ ngoại lệ cụ thể trong proguard và nó hoạt động tốt miễn là nó trong đường dẫn xây dựng. Với nhiều ngoại lệ đó, bạn cần phải bảo tồn tên của nhiều lớp học tốt. Có lẽ một cái gì đó dọc theo các dòng '-giảm lớp công khai com.google.ads. ** { bảo vệ công cộng *; } 'có hoạt động không? –

+0

Và vâng, tôi sẽ tiếp tục và bỏ qua việc thu hẹp FlurryAgent.jar :-) –

10

câu trả lời Korniltsev của việc cho tôi, tuy nhiên những trận mưa rào SDK mới (3.2.2) gợi ý thêm những điều sau đây:

-keep class com.flurry.** { *; } 
-dontwarn com.flurry.** 
-keepattributes *Annotation*,EnclosingMethod 
-keepclasseswithmembers class * { 
public <init>(android.content.Context, android.util.AttributeSet, int); 
} 

Có có thể là một số trường hợp góc mà các dòng mới được yêu cầu, vì vậy tôi đã kết thúc với README của họ.

+1

Câu trả lời này hợp lệ cho Flurry 4.2.0 – deko

3

Quan chức này đề nghị tập Proguard từ Flurry (nay thuộc sở hữu của Yahoo) có sẵn ở đây:

https://developer.yahoo.com/flurry/docs/publisher/code/android/

-­keep class com.flurry.** { *; } 
-­dontwarn com.flurry.** 
-­keepattributes *Annotation*,EnclosingMethod,Signature 
-­keepclasseswithmembers class * { 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
} 



# Google Play Services library 
-­keep class * extends java.util.ListResourceBundle { 
    protected Object[][] getContents(); 
} 

-­keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { 
    public static final *** NULL; 
} 

-­keepnames @com.google.android.gms.common.annotation.KeepName class * ­keepclassmembernames class * { 
    @com.google.android.gms.common.annotation.KeepName *; 
} 

-­keepnames class * implements android.os.Parcelable { 
    public static final ** CREATOR; 
} 
#If you are using the Google Mobile Ads SDK, add the following: 
# Preserve GMS ads classes 
-­keep class com.google.android.gms.ads.** { *; 
} 
-­dontwarn com.google.android.gms.ads.** 


#If you are using the InMobi SDK, add the following: 
# Preserve InMobi Ads classes 
-­keep class com.inmobi.** { *; 
} 
-­dontwarn com.inmobi.** 
#If you are using the Millennial Media SDK, add the following: 
# Preserve Millennial Ads classes 
-­keep class com.millennialmedia.** { *; 
} 
-­dontwarn com.millennialmedia.** 
Các vấn đề liên quan