Why does proguard ignores my rules?

Viewed 425

I've got a proguard-rules.txt which clearly is ignored by my build in android studio.

I keep getting:

Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext

and:

Note: the configuration keeps the entry point 'com.mycompany.myClass { long getMetadata(com.mycompany.Metadata,long); }', but not the descriptor class 'com.mycompany.Metadata'

Even though I have:

-dontwarn javax.naming.**

and

-keep,includedescriptorclasses public class com.mycompany.** {
    public protected *;
}
-keep,includedescriptorclasses public enum com.mycompany.** {
    public protected *;
}
-keep,includedescriptorclasses public interface com.mycompany.** {
    public protected *;
}

It's just an example, I have a lot of rules which are ignored and classes are removed even though I have a -keep rule for them. Also, the contents of the build/intermediates/proguard-rules/release/aapt_rules.txt suggest that my rules are ignored - none of them are there.

Here's my config:

build.gradle

buildTypes {
        debug {
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.txt"
        }
    }

proguard-rules.txt [part with a connection to the question]

-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.**

Could someone tell me what's going on? It seems to be done 'by the book' but I can't figure this out.

EDIT:

I just wanted to add, that the:

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, which would suggest that the rules are read because com.mycomany.myClass is kept, comes from the default android rules, which will keep classes specified in AndroidManifest.xml file. This is not because of my rules in my proguard-rules.txt file.

EDIT2: I have modified my spongycastle config to:

# SPONGYCASTLE
-keep class org.spongycastle.** {*;}
-dontwarn org.spongycastle.**
-dontwarn javax.naming.**

but I still get the same warnings about spongycastle's classes which can't find referenced classes in javax.naming.

0 Answers
Related