在APP项目的release配置中开启混淆配置,已经开启的就不用管了:
buildTypes {
debug {
}
release {
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
minifyEnabled true
// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
shrinkResources true
// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
....
在代码混淆配置proguard-rules.pro添加下面的代码:
#-------------- 去掉所有打印 -------------
-assumenosideeffects class android.util.Log {
public static *** d(...);
# public static *** e(...);
public static *** i(...);
public static *** v(...);
public static *** println(...);
public static *** w(...);
public static *** wtf(...);
}
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
-assumenosideeffects class android.util.Log {
# public static *** e(...);
public static *** v(...);
}
-assumenosideeffects class android.util.Log {
public static *** i(...);
public static *** v(...);
}
-assumenosideeffects class android.util.Log {
public static *** w(...);
public static *** v(...);
}
-assumenosideeffects class java.io.PrintStream {
public *** println(...);
public *** print(...);
}
网友评论