我希望在发布时从日志中清除我的项目。 但我正在尝试使用proguard并且结果为零: 我的项目设置:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
android.library.reference.1=..\\google-play-services_lib
我的proguard-properties
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-keepattributes LineNumberTable
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
#To remove debug logs:
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** w(...);
public static *** i(...);
}
-keep class android.support.v4.** { *; }
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Fragment
-keep public class * extends android.app.ListActivity
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembers class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class net.hockeyapp.android.UpdateFragment {
*;
}
-keepclassmembers class * {
public void onClickUpdate(android.view.View);
}
-keep public class javax.net.ssl.**
-keepclassmembers public class javax.net.ssl.** {
*;
}
-keep public class org.apache.http.**
-keepclassmembers public class org.apache.http.** {
*;
}
为什么它不起作用?我正试图关闭/开启优化......同样的结果
答案 0 :(得分:8)
如果您希望proguard-android-optimize.txt
设置有效,则必须使用assumenosideeffects
:
将proguard.config行更改为:
proguard.config = $ {sdk.dir} /工具/ proguard的/ proguard的-android-的优化强> .txt的:proguard的-project.txt
可以找到有关Eric Lafortune的proguard-android-optimize.txt
和proguard-android.txt
的更详细说明here