0

I have a file from a library module. I am not calling any methods in this file. So I expect Proguard to strip this file. But I am still seeing references in my apk. The file is :

public final class DebugUtils {
private DebugUtils(){}

public static void setAcceptSSLConnections()  {
    SSLContext sc = null;
    try {
        sc = SSLContext.getInstance("SSL");
    } catch (NoSuchAlgorithmException e) {
        //This isn't a production error since this
        // code is debug only
        throw new RuntimeException(e);
    }
    TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() {
        @Override
        public void checkClientTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

        @Override
        public void checkServerTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

        @Override
        public X509Certificate[] getAcceptedIssuers() {
            return null;
        }
    }};
    try {
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
    } catch (KeyManagementException e) {
        //This isn't a production error since this
        // code is debug only
        throw new RuntimeException(e);
    }
    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

    // Create all-trusting host name verifier
    HostnameVerifier allHostsValid = new HostnameVerifier() {
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }
    };
    // Install the all-trusting host verifier
    HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
}

}

The usage.txt(proguard generated output file) says:

com.....DebugUtils: 22:61:public static void setAcceptSSLConnections()

But I still see in my apk:

DebugUtils$1 (m)() (m)void checkClientTrusted(....) (m)java.security.cert.X%)(Certificate[] getAcceptedIssuers()

etc...

Is there any change that I can do so that Proguard completely removes this file

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
png
  • 4,368
  • 7
  • 69
  • 118
  • Move class `DebugUtils` into source-set `debug`, then it wouldn't be processed when building a release build. The file not being there might yield the desired results. One can also run Ant tasks with Gradle, eg. in order to remove all remaining references to `DebugUtils`. – Martin Zeitler Oct 30 '20 at 22:13
  • its in library, so I cant do that – png Nov 02 '20 at 15:12

0 Answers0