Java – Android : openConnection() throws IOExeption ( Unable to find default handler for protocol: http )

Android : openConnection() throws IOExeption ( Unable to find default handler for protocol: http )… here is a solution to the problem.

Android : openConnection() throws IOExeption ( Unable to find default handler for protocol: http )

I have an android app that uses the jcifs library. Every time I try to run openConnection() on a URL using the HTTP protocol, I get an IOExeption with the following message: “Unable to find default handler for protocol: http”. It works with URLs that use the FTP protocol.

After some digging, I suspect the problem is with the jcifs library. From the JCIFS docs, I found the following:

The jCIFS NTLM support is implemented as a URLStreamHandler for HTTP connections. This handler “wraps” the default handler provided by your Java environment to add support for NTLM authentication.

Add the “jcifs” package to the list of protocol handler packages. The “java.protocol.handler.pkgs” property is a pipe-separated (“|”) list of packages which supply protocol handlers to Java.The “jcifs” package should be added to this list; this would typically be done by adding “-Djava.protocol.handler.pkgs=jcifs” to the command line when starting the application…

see full article

Can anyone help with this.

Solution

Try adding this:

jcifs. Config.registerSmbURLHandler();

Before you create the connection. This will install the jcifs package in your project.

Related Problems and Solutions