The problem is as follows.
In development I use library (B), which in turn uses apache http-client.
Applying it for android (when writing unit tests), it turned out that apache-http-client from the SDK is loaded by default – its version is not compatible with (B). Solved this issue, in Intellij Idea in Dependency changed the order of dependencies by putting http-client in front of the SDK.
After that, all unit tests (Junit 4, not from the SDK, also separately, if important) passed – classes were loaded from the lib, and not from the SDK.
However, when I built apk and ran the program, the classes were loaded from the SDK and, accordingly, nothing worked. Any idea what to do?
You can try porting apache-http-client to a different namespace using jarjar.
But it's better to get rid of the library.