10

I am trying to run Proguard on my Android app and running into issues.

I am using SpongyCastle jar (copy and past of full bouncy castle with package renamed so it does not conflict with androids bouncy castle built in version)

When running proguard I see the following

How do I fix this? Add rt.jar to my libs?

The whole point of proguard is to shrink the code, but I keep adding jars to get around these issues where proguard complains it cannot find a class! Am I missing something?

[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.InitialDirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.InitialDirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchResult
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchResult
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attributes
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attribute
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attribute
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingException
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attributes
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchResult
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingException
[proguard] Warning: org.spongycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
[proguard] Note: the configuration refers to the unknown class 'android.app.backup.BackupAgentHelper'
[proguard] Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
[proguard] Note: there were 2 references to unknown classes.
[proguard]       You should check your configuration for typos.
[proguard] Warning: there were 57 unresolved references to classes or interfaces.
[proguard]          You may need to specify additional library jars (using '-libraryjars'),
[proguard]          or perhaps the '-dontskipnonpubliclibraryclasses' option.

UILD FAILED
:\AndroidSDK\android-sdk_r12-windows\android-sdk-windows\tools\ant\build.xml:713: Please correct the above warnings first.

Update

ANT Script

I used android update project --path . to generate the build.xml as the project was created sometime ago and I haven't made any changes

<?xml version="1.0" encoding="UTF-8"?>
    <project name="RootActivity" default="help">
        <loadproperties srcFile="local.properties" />
        <property file="ant.properties" />
        <loadproperties srcFile="project.properties" />
        <fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'" unless="sdk.dir" />
        <import file="${sdk.dir}/tools/ant/build.xml" />
    </project>
tommybee
  • 2,409
  • 1
  • 20
  • 23
user964283
  • 853
  • 4
  • 11
  • 16
  • Can you post the part of your ant script responsible? This seems like a problem with importing the standard java libraries in android... – SuperTron Dec 16 '11 at 22:36
  • I used android update project --path . to generate the build.xml as the project was created sometime ago and I haven't made any changes – user964283 Dec 16 '11 at 22:43
  • There is a related [issue #27612](http://code.google.com/p/android/issues/detail?id=27612). –  Sep 25 '12 at 13:02

2 Answers2

20

Add the following, -dontwarn javax.naming.** , to your Proguard configuration.

They are just warnings, and ignoring them shouldn't be an issue.

Grimmace
  • 4,021
  • 1
  • 31
  • 25
  • 9
    This is the officially recommended solution. The naming package is missing on Android, but apparently this is not causing any problems. – Eric Lafortune Dec 18 '11 at 00:39
  • For others having the same issue but with a gradle-based build (android studio) - check out this answer: http://stackoverflow.com/q/18481752/1041533 and make sure to include both proguard files correctly! The default one and yours with above statements in it – AgentKnopf Feb 06 '15 at 13:30
4

I don't think there is a need to add rt.jar to your libs. You need to make sure you are referencing it properly in your proguard script. Take a look here for an example. This line in section 2 is the money maker:

-libraryjars ${java.home}/lib/rt.jar

Although, that syntax changes if you use the xml notation for proguard. If you post the part of the ant script that is responsible I can try to be of more assistance. Hope this helps!

SuperTron
  • 4,203
  • 6
  • 35
  • 62