为什么proguard忽略了我的规则?

时间:2017-09-18 09:32:42

标签: android android-studio proguard

我有一个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中找不到引用的类。

0 个答案:

没有答案