proguard 的使用,加密jar包
下载6.2.2 的
https://download.csdn.net/download/kouwoo/12548260
系统中默认放在C:\Users\Administrator\AppData\Local\Android\Sdk\tools\proguard是4.7的
把最新的6.2.2解压缩覆盖原来的就可以了
运行bin\proguardgui.bat
在input/Output中输入你要加密的jar文件 和输出文件 ,
proguard的配置参考下面
然后进入process中saveConfiguration保存你的文件为 proguard-rules.pro
再打开你保存的proguard-rules.pro文件 ,红色的是修改过的部分,
-injars 'xxxxxx\build\libs\origin.jar'
-outjars 'xxxxxx\build\libs\origin_out.jar'
-libraryjars 'C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar'
-dontwarn javax.crypto.**,android.util.**,android.os.**,android.content.**
-keep class javax.crypto.**,android.util.**,android.os.**,android.content.**
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-keepparameternames
# Keep - Applications. Keep all application classes, along with their 'main' methods.
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver
# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
# along with the special 'createUI' method.
-keep class * extends javax.swing.plaf.ComponentUI {
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}
# Keep - Native method names. Keep all native class/method names.
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
native <methods>;
}
# Keep - _class method names. Keep all .class method names. This may be
# useful for libraries that will be obfuscated again with different obfuscators.
-keepclassmembers,allowshrinking class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String,boolean);
}
-keepclassmembers,allowshrinking class * {
@proguard.annotation.KeepName
<fields>;
@proguard.annotation.KeepName
<methods>;
}
-keepclassmembers,allowshrinking @proguard.annotation.KeepClassMemberNames class * {
<fields>;
<methods>;
}
-keepclassmembers,allowshrinking @proguard.annotation.KeepPublicClassMemberNames class * {
public <fields>;
public <methods>;
}
-keepclassmembers,allowshrinking @proguard.annotation.KeepPublicProtectedClassMemberNames class * {
public protected <fields>;
public protected <methods>;
}
-keep,allowshrinking @proguard.annotation.KeepName class *
# Remove - System method calls. Remove all invocations of System
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.System {
public static long currentTimeMillis();
static java.lang.Class getCallerClass();
public static int identityHashCode(java.lang.Object);
public static java.lang.SecurityManager getSecurityManager();
public static java.util.Properties getProperties();
public static java.lang.String getProperty(java.lang.String);
public static java.lang.String getenv(java.lang.String);
public static java.lang.String mapLibraryName(java.lang.String);
public static java.lang.String getProperty(java.lang.String,java.lang.String);
}
# Remove - Math method calls. Remove all invocations of Math
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.Math {
public static double sin(double);
public static double cos(double);
public static double tan(double);
public static double asin(double);
public static double acos(double);
public static double atan(double);
public static double toRadians(double);
public static double toDegrees(double);
public static double exp(double);
public static double log(double);
public static double log10(double);
public static double sqrt(double);
public static double cbrt(double);
public static double IEEEremainder(double,double);
public static double ceil(double);
public static double floor(double);
public static double rint(double);
public static double atan2(double,double);
public static double pow(double,double);
public static int round(float);
public static long round(double);
public static double random();
public static int abs(int);
public static long abs(long);
public static float abs(float);
public static double abs(double);
public static int max(int,int);
public static long max(long,long);
public static float max(float,float);
public static double max(double,double);
public static int min(int,int);
public static long min(long,long);
public static float min(float,float);
public static double min(double,double);
public static double ulp(double);
public static float ulp(float);
public static double signum(double);
public static float signum(float);
public static double sinh(double);
public static double cosh(double);
public static double tanh(double);
public static double hypot(double,double);
public static double expm1(double);
public static double log1p(double);
}
# Remove - Number method calls. Remove all invocations of Number
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.* extends java.lang.Number {
public static java.lang.String toString(byte);
public static java.lang.Byte valueOf(byte);
public static byte parseByte(java.lang.String);
public static byte parseByte(java.lang.String,int);
public static java.lang.Byte valueOf(java.lang.String,int);
public static java.lang.Byte valueOf(java.lang.String);
public static java.lang.Byte decode(java.lang.String);
public int compareTo(java.lang.Byte);
public static java.lang.String toString(short);
public static short parseShort(java.lang.String);
public static short parseShort(java.lang.String,int);
public static java.lang.Short valueOf(java.lang.String,int);
public static java.lang.Short valueOf(java.lang.String);
public static java.lang.Short valueOf(short);
public static java.lang.Short decode(java.lang.String);
public static short reverseBytes(short);
public int compareTo(java.lang.Short);
public static java.lang.String toString(int,int);
public static java.lang.String toHexString(int);
public static java.lang.String toOctalString(int);
public static java.lang.String toBinaryString(int);
public static java.lang.String toString(int);
public static int parseInt(java.lang.String,int);
public static int parseInt(java.lang.String);
public static java.lang.Integer valueOf(java.lang.String,int);
public static java.lang.Integer valueOf(java.lang.String);
public static java.lang.Integer valueOf(int);
public static java.lang.Integer getInteger(java.lang.String);
public static java.lang.Integer getInteger(java.lang.String,int);
public static java.lang.Integer getInteger(java.lang.String,java.lang.Integer);
public static java.lang.Integer decode(java.lang.String);
public static int highestOneBit(int);
public static int lowestOneBit(int);
public static int numberOfLeadingZeros(int);
public static int numberOfTrailingZeros(int);
public static int bitCount(int);
public static int rotateLeft(int,int);
public static int rotateRight(int,int);
public static int reverse(int);
public static int signum(int);
public static int reverseBytes(int);
public int compareTo(java.lang.Integer);
public static java.lang.String toString(long,int);
public static java.lang.String toHexString(long);
public static java.lang.String toOctalString(long);
public static java.lang.String toBinaryString(long);
public static java.lang.String toString(long);
public static long parseLong(java.lang.String,int);
public static long parseLong(java.lang.String);
public static java.lang.Long valueOf(java.lang.String,int);
public static java.lang.Long valueOf(java.lang.String);
public static java.lang.Long valueOf(long);
public static java.lang.Long decode(java.lang.String);
public static java.lang.Long getLong(java.lang.String);
public static java.lang.Long getLong(java.lang.String,long);
public static java.lang.Long getLong(java.lang.String,java.lang.Long);
public static long highestOneBit(long);
public static long lowestOneBit(long);
public static int numberOfLeadingZeros(long);
public static int numberOfTrailingZeros(long);
public static int bitCount(long);
public static long rotateLeft(long,int);
public static long rotateRight(long,int);
public static long reverse(long);
public static int signum(long);
public static long reverseBytes(long);
public int compareTo(java.lang.Long);
public static java.lang.String toString(float);
public static java.lang.String toHexString(float);
public static java.lang.Float valueOf(java.lang.String);
public static java.lang.Float valueOf(float);
public static float parseFloat(java.lang.String);
public static boolean isNaN(float);
public static boolean isInfinite(float);
public static int floatToIntBits(float);
public static int floatToRawIntBits(float);
public static float intBitsToFloat(int);
public static int compare(float,float);
public boolean isNaN();
public boolean isInfinite();
public int compareTo(java.lang.Float);
public static java.lang.String toString(double);
public static java.lang.String toHexString(double);
public static java.lang.Double valueOf(java.lang.String);
public static java.lang.Double valueOf(double);
public static double parseDouble(java.lang.String);
public static boolean isNaN(double);
public static boolean isInfinite(double);
public static long doubleToLongBits(double);
public static long doubleToRawLongBits(double);
public static double longBitsToDouble(long);
public static int compare(double,double);
public boolean isNaN();
public boolean isInfinite();
public int compareTo(java.lang.Double);
public byte byteValue();
public short shortValue();
public int intValue();
public long longValue();
public float floatValue();
public double doubleValue();
public int compareTo(java.lang.Object);
public boolean equals(java.lang.Object);
public int hashCode();
public java.lang.String toString();
}
# Remove - String method calls. Remove all invocations of String
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.String {
public static java.lang.String copyValueOf(char[]);
public static java.lang.String copyValueOf(char[],int,int);
public static java.lang.String valueOf(boolean);
public static java.lang.String valueOf(char);
public static java.lang.String valueOf(char[]);
public static java.lang.String valueOf(char[],int,int);
public static java.lang.String valueOf(double);
public static java.lang.String valueOf(float);
public static java.lang.String valueOf(int);
public static java.lang.String valueOf(java.lang.Object);
public static java.lang.String valueOf(long);
public boolean contentEquals(java.lang.StringBuffer);
public boolean endsWith(java.lang.String);
public boolean equalsIgnoreCase(java.lang.String);
public boolean equals(java.lang.Object);
public boolean matches(java.lang.String);
public boolean regionMatches(boolean,int,java.lang.String,int,int);
public boolean regionMatches(int,java.lang.String,int,int);
public boolean startsWith(java.lang.String);
public boolean startsWith(java.lang.String,int);
public byte[] getBytes();
public byte[] getBytes(java.lang.String);
public char charAt(int);
public char[] toCharArray();
public int compareToIgnoreCase(java.lang.String);
public int compareTo(java.lang.Object);
public int compareTo(java.lang.String);
public int hashCode();
public int indexOf(int);
public int indexOf(int,int);
public int indexOf(java.lang.String);
public int indexOf(java.lang.String,int);
public int lastIndexOf(int);
public int lastIndexOf(int,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.CharSequence subSequence(int,int);
public java.lang.String concat(java.lang.String);
public java.lang.String replaceAll(java.lang.String,java.lang.String);
public java.lang.String replace(char,char);
public java.lang.String replaceFirst(java.lang.String,java.lang.String);
public java.lang.String[] split(java.lang.String);
public java.lang.String[] split(java.lang.String,int);
public java.lang.String substring(int);
public java.lang.String substring(int,int);
public java.lang.String toLowerCase();
public java.lang.String toLowerCase(java.util.Locale);
public java.lang.String toString();
public java.lang.String toUpperCase();
public java.lang.String toUpperCase(java.util.Locale);
public java.lang.String trim();
}
# Remove - StringBuffer method calls. Remove all invocations of StringBuffer
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.StringBuffer {
public java.lang.String toString();
public char charAt(int);
public int capacity();
public int codePointAt(int);
public int codePointBefore(int);
public int indexOf(java.lang.String,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
# Remove - StringBuilder method calls. Remove all invocations of StringBuilder
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.StringBuilder {
public java.lang.String toString();
public char charAt(int);
public int capacity();
public int codePointAt(int);
public int codePointBefore(int);
public int indexOf(java.lang.String,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
这时点击Proguard/LoadConfiguration,重截入proguard-rules.pro,点击Process
输出如下,则表示成功!
ProGuard, version 6.2.2
Reading program jar [D:\working\Android\DaLian_forensicsphone\DaLian_forensicsphone\BK_Check\check_aj_file\build\libs\origin.jar] (filtered)
Reading library jar [C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar] (filtered)
Note: the configuration refers to the unknown class 'proguard.annotation.KeepName'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepName'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepClassMemberNames'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepPublicClassMemberNames'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepPublicProtectedClassMemberNames'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepName'
Note: com.example.check_aj_file.testFile: can't find dynamically referenced class android.os.SystemProperties
Note: com.example.check_aj_file.testFile accesses a method 'get(java.lang.String,java.lang.String)' dynamically
Maybe this is library method 'com.sun.xml.internal.bind.v2.util.QNameMap { java.lang.Object get(java.lang.String,java.lang.String); }'
Maybe this is library method 'com.sun.xml.internal.ws.api.message.HeaderList { com.sun.xml.internal.ws.api.message.Header get(java.lang.String,java.lang.String); }'
Maybe this is library method 'com.sun.xml.internal.ws.util.QNameMap { java.lang.Object get(java.lang.String,java.lang.String); }'
Maybe this is library method 'java.util.prefs.AbstractPreferences { java.lang.String get(java.lang.String,java.lang.String); }'
Maybe this is library method 'java.util.prefs.Preferences { java.lang.String get(java.lang.String,java.lang.String); }'
Maybe this is library method 'sun.net.www.protocol.http.AuthCache { sun.net.www.protocol.http.AuthCacheValue get(java.lang.String,java.lang.String); }'
Maybe this is library method 'sun.net.www.protocol.http.AuthCacheImpl { sun.net.www.protocol.http.AuthCacheValue get(java.lang.String,java.lang.String); }'
Note: there were 6 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 1 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 1 accesses to class members by means of reflection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Preparing output jar
Processing completed successfully
如果提示失败
ProGuard, version 6.2.2
Reading program jar [D:\working\Android\DaLian_forensicsphone\DaLian_forensicsphone\BK_Check\check_aj_file\build\libs\origin.jar] (filtered)
Reading library jar [C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar] (filtered)
Note: the configuration refers to the unknown class 'proguard.annotation.KeepName'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepName'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepClassMemberNames'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepPublicClassMemberNames'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepPublicProtectedClassMemberNames'
Note: the configuration refers to the unknown class 'proguard.annotation.KeepName'
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.HandlerThread
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.HandlerThread
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.Handler
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.HandlerThread
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.Handler
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.HandlerThread
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.HandlerThread
Warning: com.example.check_aj_file.a.d: can't find referenced class android.os.HandlerThread
Note: com.example.check_aj_file.testFile: can't find dynamically referenced class android.os.SystemProperties
Note: there were 6 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 1 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 8 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Please correct the above warnings first.
则把红色warning部分的包加入到proguard-rules.pro中的
-dontwarn android.os.**
-keep class android.os.**
之后就可以正常混淆了
最好可以把 proguard-rules.pro复制到工程中的proguard-rules.pro中
要注释前三行
代码如下
proguard-rules.pro
#-injars '..\check_aj_file\build\libs\origin.jar'
#-outjars '。。\check_aj_file\build\libs\origin_out.jar'
#-libraryjars 'C:\Program Files\Java\jdk1.8.0_152\jre\lib\rt.jar'
-dontwarn javax.crypto.**,android.util.**,android.os.**,android.content.**
-keep class javax.crypto.**,android.util.**,android.os.**,android.content.**
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-keepparameternames
# Keep - Applications. Keep all application classes, along with their 'main' methods.
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver
# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
# along with the special 'createUI' method.
-keep class * extends javax.swing.plaf.ComponentUI {
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}
# Keep - Native method names. Keep all native class/method names.
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
native <methods>;
}
# Keep - _class method names. Keep all .class method names. This may be
# useful for libraries that will be obfuscated again with different obfuscators.
-keepclassmembers,allowshrinking class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String,boolean);
}
-keepclassmembers,allowshrinking class * {
@proguard.annotation.KeepName
<fields>;
@proguard.annotation.KeepName
<methods>;
}
-keepclassmembers,allowshrinking @proguard.annotation.KeepClassMemberNames class * {
<fields>;
<methods>;
}
-keepclassmembers,allowshrinking @proguard.annotation.KeepPublicClassMemberNames class * {
public <fields>;
public <methods>;
}
-keepclassmembers,allowshrinking @proguard.annotation.KeepPublicProtectedClassMemberNames class * {
public protected <fields>;
public protected <methods>;
}
-keep,allowshrinking @proguard.annotation.KeepName class *
# Remove - System method calls. Remove all invocations of System
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.System {
public static long currentTimeMillis();
static java.lang.Class getCallerClass();
public static int identityHashCode(java.lang.Object);
public static java.lang.SecurityManager getSecurityManager();
public static java.util.Properties getProperties();
public static java.lang.String getProperty(java.lang.String);
public static java.lang.String getenv(java.lang.String);
public static java.lang.String mapLibraryName(java.lang.String);
public static java.lang.String getProperty(java.lang.String,java.lang.String);
}
# Remove - Math method calls. Remove all invocations of Math
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.Math {
public static double sin(double);
public static double cos(double);
public static double tan(double);
public static double asin(double);
public static double acos(double);
public static double atan(double);
public static double toRadians(double);
public static double toDegrees(double);
public static double exp(double);
public static double log(double);
public static double log10(double);
public static double sqrt(double);
public static double cbrt(double);
public static double IEEEremainder(double,double);
public static double ceil(double);
public static double floor(double);
public static double rint(double);
public static double atan2(double,double);
public static double pow(double,double);
public static int round(float);
public static long round(double);
public static double random();
public static int abs(int);
public static long abs(long);
public static float abs(float);
public static double abs(double);
public static int max(int,int);
public static long max(long,long);
public static float max(float,float);
public static double max(double,double);
public static int min(int,int);
public static long min(long,long);
public static float min(float,float);
public static double min(double,double);
public static double ulp(double);
public static float ulp(float);
public static double signum(double);
public static float signum(float);
public static double sinh(double);
public static double cosh(double);
public static double tanh(double);
public static double hypot(double,double);
public static double expm1(double);
public static double log1p(double);
}
# Remove - Number method calls. Remove all invocations of Number
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.* extends java.lang.Number {
public static java.lang.String toString(byte);
public static java.lang.Byte valueOf(byte);
public static byte parseByte(java.lang.String);
public static byte parseByte(java.lang.String,int);
public static java.lang.Byte valueOf(java.lang.String,int);
public static java.lang.Byte valueOf(java.lang.String);
public static java.lang.Byte decode(java.lang.String);
public int compareTo(java.lang.Byte);
public static java.lang.String toString(short);
public static short parseShort(java.lang.String);
public static short parseShort(java.lang.String,int);
public static java.lang.Short valueOf(java.lang.String,int);
public static java.lang.Short valueOf(java.lang.String);
public static java.lang.Short valueOf(short);
public static java.lang.Short decode(java.lang.String);
public static short reverseBytes(short);
public int compareTo(java.lang.Short);
public static java.lang.String toString(int,int);
public static java.lang.String toHexString(int);
public static java.lang.String toOctalString(int);
public static java.lang.String toBinaryString(int);
public static java.lang.String toString(int);
public static int parseInt(java.lang.String,int);
public static int parseInt(java.lang.String);
public static java.lang.Integer valueOf(java.lang.String,int);
public static java.lang.Integer valueOf(java.lang.String);
public static java.lang.Integer valueOf(int);
public static java.lang.Integer getInteger(java.lang.String);
public static java.lang.Integer getInteger(java.lang.String,int);
public static java.lang.Integer getInteger(java.lang.String,java.lang.Integer);
public static java.lang.Integer decode(java.lang.String);
public static int highestOneBit(int);
public static int lowestOneBit(int);
public static int numberOfLeadingZeros(int);
public static int numberOfTrailingZeros(int);
public static int bitCount(int);
public static int rotateLeft(int,int);
public static int rotateRight(int,int);
public static int reverse(int);
public static int signum(int);
public static int reverseBytes(int);
public int compareTo(java.lang.Integer);
public static java.lang.String toString(long,int);
public static java.lang.String toHexString(long);
public static java.lang.String toOctalString(long);
public static java.lang.String toBinaryString(long);
public static java.lang.String toString(long);
public static long parseLong(java.lang.String,int);
public static long parseLong(java.lang.String);
public static java.lang.Long valueOf(java.lang.String,int);
public static java.lang.Long valueOf(java.lang.String);
public static java.lang.Long valueOf(long);
public static java.lang.Long decode(java.lang.String);
public static java.lang.Long getLong(java.lang.String);
public static java.lang.Long getLong(java.lang.String,long);
public static java.lang.Long getLong(java.lang.String,java.lang.Long);
public static long highestOneBit(long);
public static long lowestOneBit(long);
public static int numberOfLeadingZeros(long);
public static int numberOfTrailingZeros(long);
public static int bitCount(long);
public static long rotateLeft(long,int);
public static long rotateRight(long,int);
public static long reverse(long);
public static int signum(long);
public static long reverseBytes(long);
public int compareTo(java.lang.Long);
public static java.lang.String toString(float);
public static java.lang.String toHexString(float);
public static java.lang.Float valueOf(java.lang.String);
public static java.lang.Float valueOf(float);
public static float parseFloat(java.lang.String);
public static boolean isNaN(float);
public static boolean isInfinite(float);
public static int floatToIntBits(float);
public static int floatToRawIntBits(float);
public static float intBitsToFloat(int);
public static int compare(float,float);
public boolean isNaN();
public boolean isInfinite();
public int compareTo(java.lang.Float);
public static java.lang.String toString(double);
public static java.lang.String toHexString(double);
public static java.lang.Double valueOf(java.lang.String);
public static java.lang.Double valueOf(double);
public static double parseDouble(java.lang.String);
public static boolean isNaN(double);
public static boolean isInfinite(double);
public static long doubleToLongBits(double);
public static long doubleToRawLongBits(double);
public static double longBitsToDouble(long);
public static int compare(double,double);
public boolean isNaN();
public boolean isInfinite();
public int compareTo(java.lang.Double);
public byte byteValue();
public short shortValue();
public int intValue();
public long longValue();
public float floatValue();
public double doubleValue();
public int compareTo(java.lang.Object);
public boolean equals(java.lang.Object);
public int hashCode();
public java.lang.String toString();
}
# Remove - String method calls. Remove all invocations of String
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.String {
public static java.lang.String copyValueOf(char[]);
public static java.lang.String copyValueOf(char[],int,int);
public static java.lang.String valueOf(boolean);
public static java.lang.String valueOf(char);
public static java.lang.String valueOf(char[]);
public static java.lang.String valueOf(char[],int,int);
public static java.lang.String valueOf(double);
public static java.lang.String valueOf(float);
public static java.lang.String valueOf(int);
public static java.lang.String valueOf(java.lang.Object);
public static java.lang.String valueOf(long);
public boolean contentEquals(java.lang.StringBuffer);
public boolean endsWith(java.lang.String);
public boolean equalsIgnoreCase(java.lang.String);
public boolean equals(java.lang.Object);
public boolean matches(java.lang.String);
public boolean regionMatches(boolean,int,java.lang.String,int,int);
public boolean regionMatches(int,java.lang.String,int,int);
public boolean startsWith(java.lang.String);
public boolean startsWith(java.lang.String,int);
public byte[] getBytes();
public byte[] getBytes(java.lang.String);
public char charAt(int);
public char[] toCharArray();
public int compareToIgnoreCase(java.lang.String);
public int compareTo(java.lang.Object);
public int compareTo(java.lang.String);
public int hashCode();
public int indexOf(int);
public int indexOf(int,int);
public int indexOf(java.lang.String);
public int indexOf(java.lang.String,int);
public int lastIndexOf(int);
public int lastIndexOf(int,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.CharSequence subSequence(int,int);
public java.lang.String concat(java.lang.String);
public java.lang.String replaceAll(java.lang.String,java.lang.String);
public java.lang.String replace(char,char);
public java.lang.String replaceFirst(java.lang.String,java.lang.String);
public java.lang.String[] split(java.lang.String);
public java.lang.String[] split(java.lang.String,int);
public java.lang.String substring(int);
public java.lang.String substring(int,int);
public java.lang.String toLowerCase();
public java.lang.String toLowerCase(java.util.Locale);
public java.lang.String toString();
public java.lang.String toUpperCase();
public java.lang.String toUpperCase(java.util.Locale);
public java.lang.String trim();
}
# Remove - StringBuffer method calls. Remove all invocations of StringBuffer
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.StringBuffer {
public java.lang.String toString();
public char charAt(int);
public int capacity();
public int codePointAt(int);
public int codePointBefore(int);
public int indexOf(java.lang.String,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
# Remove - StringBuilder method calls. Remove all invocations of StringBuilder
# methods without side effects whose return values are not used.
-assumenosideeffects public class java.lang.StringBuilder {
public java.lang.String toString();
public char charAt(int);
public int capacity();
public int codePointAt(int);
public int codePointBefore(int);
public int indexOf(java.lang.String,int);
public int lastIndexOf(java.lang.String);
public int lastIndexOf(java.lang.String,int);
public int length();
public java.lang.String substring(int);
public java.lang.String substring(int,int);
}
然后在build.gradle中加入
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
// 混淆
minifyEnabled true
// Zipalign优化
zipAlignEnabled true
// 混淆配置
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
就可以直接在工程中进行混淆了。
附
build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
compileOptions.encoding = "utf-8"
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
ndk{
moduleName "JniLib"
abiFilters "armeabi-v7a","arm64-v8a" //输出指定的三种abi体系下的so库"armeabi",只加载armabi架构(目录下)的so库,如果是别的架构,就会找不到
}
sourceSets{ //不配的话都会有一个默认值 可以指定哪些源文件(或文件夹下的源文件)要被编译,哪些源文件要被排除
main{
jni.srcDirs = [] //禁用as自动生成mk
//jniLibs.srcDirs = ['src/main/libs','libs']
//jniLibs.srcDirs=["src/main/libs" ] //so包就去src/main/libs目录下找
}
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
// 混淆
minifyEnabled true
// Zipalign优化
zipAlignEnabled true
// 混淆配置
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
task makeJar(type: Copy) {
delete 'build/libs/origin.jar' //删除存在的
archivesBaseName = 'origin' //输出的jar包名称
from(project.zipTree('build/intermediates/aar_main_jar/release/classes.jar'))
from fileTree(dir: "src/main/java", include: "**/*.jet") //把src/main/java目录下包含的所有.jet文件封装到jar包
destinationDir = file('build/libs') //打成jar包后存放的文件目录
}
externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
}
}
makeJar.dependsOn(build)
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
本文地址:https://blog.csdn.net/babytiger/article/details/107154094