Gradle build is much longer when 4g modem is connected to the PC

Android Studio version 2.1.3, Gradle 2.14.1.

Without 4g modem Gradle works fast and usually takes 4-6 seconds to build the project, but with the modem (or smartphone connected via USB) it takes much longer, about 2 minutes. How to fix this?

I couldn’t find any similar questions and I would appreciate any help.

p.s. This task takes most of the time: Gradle build using tasks: [:desktop:assemble, :core:assemble].
“Offline work” mode doesn’t help. There is no internet activity while this task is executing.