I managed to solve it as follows. Go to the following folder:
cd /etc/apt/apt.conf.d
Create a file called 10proxy :
sudo nano 10proxy
Without authentication, add the following line:
Acquire::http::Proxy "http://yourproxyaddress:proxyport/";
Authenticated:
Acquire::http::Proxy "http://username: password@yourproxyaddress :proxyport/";
/ at the very end was important. It didn't work without him.
source share