我想使用proguard只删除日志语句,但现在我的应用程序在启动时崩溃了。我对proguard不太熟悉,但我想我必须添加一些行来保持我的其他课程没问题。
这是我的proguard-project.txt:
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-assumenosideeffects class android.util.Log { *; }
#ProGuard may remove code that it thinks you don't use such as:
#a class that is referenced only in the AndroidManifest.xml file
#a method called from JNI
#dynamically referenced fields and methods
#-keep public class <MyClass>
我如何为所有其他课程添加一个“忽视”proguard的声明?我只是想确保删除日志工作。接下来我会集中精力进行模糊处理。
我正在尝试这个,但导出时出错:
-keep class com.finesspro.gui** { * }
答案 0 :(得分:2)
在proguard-rules.pro
-dontwarn **
-target 1.7
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!code/allocation/variable
-keep class **
-keepclassmembers class *{*;}
-keepattributes *
-assumenosideeffects class android.util.Log {
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
}
在gradle.build
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
答案 1 :(得分:0)
你应该试着这个让你上课:(与“;”不同的语法)
-keep class com.finesspro.** { *; }
你应该尝试 proguard-android-optimize.txt 而不是这个,在那里打开优化! 之后你也可以使用它:
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
编辑:如果您想保留其他课程,您还需要将它们添加到proguard文件中。 例如,对于actionbarsherlock:
# For ActionbarSherlock
-keep class com.actionbarsherlock.** {*;}
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }