У меня есть несколько вопросов о конфигурации Proguard:
- Почему Proguard не запутывает мой класс этим кодом?
Java
public static String encrypt(String keyString, String text) {
try {
Cipher cipher = Cipher.getInstance(...);
...
byte[] key = new byte[...];
...
SecretKeySpec keySpec = new SecretKeySpec(key, ...);
byte[] encrypted = cipher.doFinal(text.getBytes(...));
return ...
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
build.gradle
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.config
}
}
Proguard
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
-keepclassmembers class **.R$* {public static <fields>;}
-keep class **.R$*
-keepattributes JavaScriptInterface
# If you want to enable optimization, you should include the
# following:
# -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# -optimizationpasses 5
# -allowaccessmodification
#
# Note that you cannot just include these flags in your own
# configuration file; if you are including this file, optimization
# will be turned off. You'll need to either edit this file, or
# duplicate the contents of this file and remove the include of this
# file from your project's proguard.config path property.
-keepattributes *Annotation*
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
# -keepclasseswithmembernames class * {
# native <methods>;
# }
-assumenosideeffects class android.util.Log {
public static int d(...);
public static int v(...);
public static int i(...);
public static int w(...);
public static int e(...);
}
-keep public 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*(...);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembernames 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.**
Что может быть не так, чтобы предотвратить запутывание моего кода?
Что я узнаю, не запутывайте Активность и Фрагмент с помощью Proguard, я прав?
Proguard не может запутать strings.xml
и вместо этого заменить строки в коде Java?