我有一个proguard-rules.txt
明显被我在android studio中的构建忽略了。
我一直在:
Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
和
Note: the configuration keeps the entry point 'com.mycompany.myClass { long getMetadata(com.mycompany.Metadata,long); }', but not the descriptor class 'com.mycompany.Metadata'
即使我有:
-dontwarn javax.naming.**
和
-keep,includedescriptorclasses public class com.mycompany.** {
public protected *;
}
-keep,includedescriptorclasses public enum com.mycompany.** {
public protected *;
}
-keep,includedescriptorclasses public interface com.mycompany.** {
public protected *;
}
这只是一个例子,我有很多规则被忽略,即使我有-keep
规则,也会删除类。此外,build/intermediates/proguard-rules/release/aapt_rules.txt
的内容表明我的规则被忽略 - 它们都没有。
这是我的配置:
的build.gradle
buildTypes {
debug {
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.txt"
}
}
proguard-rules.txt [与问题有关的部分]
-keepattributes Exceptions
-keepattributes Signature
-keepattributes *Annotation*
-keep,includedescriptorclasses public class com.mycompany.** {
public protected *;
}
-keep,includedescriptorclasses public enum com.mycompany.** {
public protected *;
}
-keep,includedescriptorclasses public interface com.mycompany.** {
public protected *;
}
# SPONGYCASTLE
-keep class org.spongycastle.crypto.* {*;}
-keep class org.spongycastle.crypto.agreement.** {*;}
-keep class org.spongycastle.crypto.digests.* {*;}
-keep class org.spongycastle.crypto.ec.* {*;}
-keep class org.spongycastle.crypto.encodings.* {*;}
-keep class org.spongycastle.crypto.engines.* {*;}
-keep class org.spongycastle.crypto.macs.* {*;}
-keep class org.spongycastle.crypto.modes.* {*;}
-keep class org.spongycastle.crypto.paddings.* {*;}
-keep class org.spongycastle.crypto.params.* {*;}
-keep class org.spongycastle.crypto.prng.* {*;}
-keep class org.spongycastle.crypto.signers.* {*;}
-keep class org.spongycastle.jcajce.provider.asymmetric.* {*;}
-keep class org.spongycastle.jcajce.provider.asymmetric.util.* {*;}
-keep class org.spongycastle.jcajce.provider.asymmetric.dh.* {*;}
-keep class org.spongycastle.jcajce.provider.asymmetric.ec.* {*;}
-keep class org.spongycastle.jcajce.provider.digest.** {*;}
-keep class org.spongycastle.jcajce.provider.keystore.** {*;}
-keep class org.spongycastle.jcajce.provider.symmetric.** {*;}
-keep class org.spongycastle.jcajce.spec.* {*;}
-keep class org.spongycastle.jce.** {*;}
-dontwarn javax.naming.**
有人能告诉我发生了什么事吗?这似乎是“通过书本”完成的,但我无法弄清楚这一点。
修改
我只想补充一下:
Note: the configuration keeps the entry point 'com.mycompany.myClass { long getMetadata(com.mycompany.Metadata,long); }', but not the descriptor class 'com.mycompany.Metadata'
log,它会建议读取规则,因为保留了com.mycomany.myClass
,来自默认的android规则,它将保留AndroidManifest.xml
文件中指定的类。这不是因为我的proguard-rules.txt
文件中的规则。
EDIT2: 我已将我的spongycastle配置修改为:
# SPONGYCASTLE
-keep class org.spongycastle.** {*;}
-dontwarn org.spongycastle.**
-dontwarn javax.naming.**
但是我仍然得到关于spongycastle的类的警告,这些类在javax.naming
中找不到引用的类。