Android : Override a certain class in a library dependency

Viewed 1152

I am using crosswalk as webview in my project, now I want to override a replace class for some purposes.

original class

org.xwalk.core.internal

imports....

class SslUtil {

    public static boolean shouldDenyRequest(int error) {
        switch(error) {
            case NetError.ERR_CERT_COMMON_NAME_INVALID:
            case NetError.ERR_CERT_DATE_INVALID:
            case NetError.ERR_CERT_AUTHORITY_INVALID:
            case NetError.ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
            case NetError.ERR_CERT_WEAK_KEY:
            case NetError.ERR_CERT_NAME_CONSTRAINT_VIOLATION:
            case NetError.ERR_CERT_VALIDITY_TOO_LONG:
            case NetError.ERR_CERT_CONTAINS_ERRORS:
            case NetError.ERR_CERT_REVOKED:
            case NetError.ERR_CERT_INVALID:
            case NetError.ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY:
            case NetError.ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN:
            return true;
        default:
            break;
        }
        return false;
    }
}

Now what I want to do is to replace it by copying the package name and the classe nam.

org.xwalk.core.internal

imports....

class SslUtil {

    public static boolean shouldDenyRequest(int error) {
        //I'll do my custom handling of error
        return false;
    }
}

This is possible when I'm just running with Android Studio because the IDE asks me what SslUtil should I be using. However I won't be able to generate a signed APK because of the duplicate file

(org.xwalk.core.internal.SslUtil)

Now is there a way wherein I can exclude this certain file from my dependency and use the one I created? Or is it impossible?

1 Answers
Related