Android: openConnection () throws an IOExeption (cannot find the default handler for the protocol: http)

I have an android app that uses jcifs library. Each time I try to open the connection () at the URL using the HTTP protocol, I get an IOExeption message with the following message "Cannot find the default handler for the protocol: http". It works great with URLs using FTP protocol.

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

JCIFS NTLM support is implemented as an HTTPStreamHandler for HTTP connections. This handler wraps the default handler provided by your Java environment to add NTLM authentication support.

Add the jcifs package to the list of protocol handler packages. The java.protocol.handler.pkgs property is a list of packages separated by channels ("|") that the Java protocol handlers transmit. The jcifs package should be added to this list; this is usually done by adding "-Djava.protocol.handler.pkgs = jcifs" to the command line when the application starts ...

view full article

Help solve this problem.

+4
source share
1 answer

Try adding this:

jcifs.Config.registerSmbURLHandler(); 

before creating a connection. This will install the jcifs package in your project.

0
source

Source: https://habr.com/ru/post/1489868/


All Articles